Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

1.1 KB
Raw Blame
using Grand.Business.Core.Interfaces.Common.Directory;
using Grand.Domain.Tasks;
using Grand.Infrastructure.Mapper;
using Grand.Web.AdminShared.Models.Tasks;
using Grand.Web.Common.Extensions;

namespace Grand.Web.AdminShared.Extensions.Mapping;

public static class ScheduleTaskMappingExtensions
{
    public static ScheduleTaskModel ToModel(this ScheduleTask entity, IDateTimeService dateTimeService)
    {
        var taskModel = entity.MapTo<ScheduleTask, ScheduleTaskModel>();
        taskModel.LastStartUtc = entity.LastStartUtc.ConvertToUserTime(dateTimeService);
        taskModel.LastSuccessUtc = entity.LastSuccessUtc.ConvertToUserTime(dateTimeService);
        taskModel.LastEndUtc = entity.LastNonSuccessEndUtc.ConvertToUserTime(dateTimeService);
        return taskModel;
    }

    public static ScheduleTask ToEntity(this ScheduleTaskModel model)
    {
        return model.MapTo<ScheduleTaskModel, ScheduleTask>();
    }

    public static ScheduleTask ToEntity(this ScheduleTaskModel model, ScheduleTask destination)
    {
        return model.MapTo(destination);
    }
}