Interface IAutoshipService
Service for managing associate's autoships.
Namespace: DirectScale.Disco.Extension.Services
Assembly: DirectScale.Disco.Extension.Abstractions.dll
Syntax
public interface IAutoshipService
Methods
CalculateNextProcessDate(DateTime, DateTime, Frequency)
Returns the next date after lastProcessDate
that an autoship with specified frequency
could run.
Declaration
Task<DateTime> CalculateNextProcessDate(DateTime startDate, DateTime lastProcessDate, Frequency frequency)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | startDate | The date the autoship started, this is so the next autoship happens on the same day of the week/month etc. |
System.DateTime | lastProcessDate | The last time the autoship ran. |
Frequency | frequency | How often the autoship should run. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.DateTime> | The next date the autoship can process. |
Remarks
This will usually just return lastProcessDate
+ frequency
, but sometimes an autoship will fail or be delayed which will cause the autoship to run late that week/month. startDate
will be used to make sure the next autoship will run on the correct day of the week/month.
CreateAutoship(Autoship)
Creates a new autoship
.
Declaration
Task<int> CreateAutoship(Autoship autoship)
Parameters
Type | Name | Description |
---|---|---|
Autoship | autoship | The new Autoship to create. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Int32> | New AutoshipId |
Remarks
Inserts new autoship
into DB and returns new recordnumber.
Exceptions
Type | Condition |
---|---|
System.Exception |
|
See Also
DeleteAutoship(Int32, String)
Delete a autoship.
Declaration
Task DeleteAutoship(int autoshipId, string message)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | autoshipId | The autoship record number to delete. |
System.String | message | The reason or notes to log. 255 character limit. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Exceptions
Type | Condition |
---|---|
System.Exception | Autoship not found. |
GetAutoship(Int32, Boolean)
Reads autoship record from DB by the autoship's autoshipId
.
Declaration
Task<Autoship> GetAutoship(int autoshipId, bool includeLineItems = true)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | autoshipId | The AutoshipId to read. |
System.Boolean | includeLineItems | True to do an additional read to populate LineItems, defaults to true. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Autoship> | The autoship found, or a default Autoship object create, but all fields empty/null. |
See Also
GetAutoships(Int32, Boolean)
Reads all of an associate's autoships from DB.
Declaration
Task<Autoship[]> GetAutoships(int associateId, bool includeServiceAutoships)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | associateId | Associate to read autoships for. |
System.Boolean | includeServiceAutoships | Set to false to filter autoships with type of YearlyRenewal. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Autoship[]> | The autoships found, or an empty array. |
See Also
GetAutoshipsByProcessDate(DateTime)
Declaration
Task<Autoship[]> GetAutoshipsByProcessDate(DateTime nextProcessDate)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | nextProcessDate |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Autoship[]> |
ProcessAutoships(Int32[])
Declaration
Task ProcessAutoships(int[] autoshipIds)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | autoshipIds |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
UpdateAutoship(Autoship)
Modifies an existing autoship
.
Declaration
Task<int> UpdateAutoship(Autoship autoship)
Parameters
Type | Name | Description |
---|---|---|
Autoship | autoship | The Autoship to modify. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Int32> |
Remarks
Does not update LastProcessDate, use
Exceptions
Type | Condition |
---|---|
System.Exception |
|