Search Results for

    Show / Hide Table of Contents

    Class AutoshipService

    Inheritance
    System.Object
    AutoshipService
    Implements
    IAutoshipService
    Namespace: DirectScale.Disco.Extension.Services
    Assembly: DirectScale.Disco.Extension.Abstractions.dll
    Syntax
    public class AutoshipService : Object, IAutoshipService

    Constructors

    AutoshipService(IApiService)

    Declaration
    public AutoshipService(IApiService apiService)
    Parameters
    Type Name Description
    IApiService apiService

    Methods

    CalculateNextProcessDate(DateTime, DateTime, Frequency)

    Returns the next date after lastProcessDate that an autoship with specified frequency could run.

    Declaration
    public 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
    public 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

    autoship is invalid.

    See Also
    UpdateAutoship(Autoship)

    DeleteAutoship(Int32, String)

    Delete a autoship.

    Declaration
    public 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
    public 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)

    GetAutoships(Int32, Boolean)

    Reads all of an associate's autoships from DB.

    Declaration
    public 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
    GetAutoship(Int32, Boolean)

    GetAutoshipsByProcessDate(DateTime)

    Declaration
    public Task<Autoship[]> GetAutoshipsByProcessDate(DateTime nextProcessDate)
    Parameters
    Type Name Description
    System.DateTime nextProcessDate
    Returns
    Type Description
    System.Threading.Tasks.Task<Autoship[]>

    ProcessAutoships(Int32[])

    Declaration
    public 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
    public Task<int> UpdateAutoship(Autoship autoship)
    Parameters
    Type Name Description
    Autoship autoship

    The Autoship to modify.

    Returns
    Type Description
    System.Threading.Tasks.Task<System.Int32>

    AutoshipId

    Remarks

    Does not update LastProcessDate, use . LastChargeAmount is set by summing LineItems prices.

    Exceptions
    Type Condition
    System.Exception

    autoship is invalid or doesn't already exist.

    See Also
    CreateAutoship(Autoship)

    Implements

    IAutoshipService
    In This Article
    Back to top Copyright © 2022 DirectScale
    Generated by DocFX