89 lines
2.9 KiB
C#
89 lines
2.9 KiB
C#
using CompanyManagment.App.Contracts.RollCallService;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using _0_Framework.Application;
|
|
using Company.Domain.RollCallServiceAgg;
|
|
using AccountManagement.Domain.AccountAgg;
|
|
using Microsoft.Identity.Client;
|
|
|
|
namespace CompanyManagment.Application;
|
|
|
|
public class RollCallServiceApplication : IRollCallServiceApplication
|
|
{
|
|
private readonly IRollCallServiceRepository _rollCallServiceRepository;
|
|
|
|
public RollCallServiceApplication(IRollCallServiceRepository rollCallServiceRepository)
|
|
{
|
|
_rollCallServiceRepository = rollCallServiceRepository;
|
|
}
|
|
|
|
public OperationResult Create(CreateRollCallService command)
|
|
{
|
|
var opration = new OperationResult();
|
|
if (_rollCallServiceRepository.Exists(x =>
|
|
x.WorkshopId == command.WorkshopId && x.AccountId == command.AccountId && x.IsActiveString == "true"))
|
|
return opration.Failed("برای این کارگاه قبلا سرویس فعال شده است");
|
|
//var start = DateTime.Now
|
|
//var create = new RollCallService(command.ServiceType, start,)
|
|
|
|
var create = new RollCallService(
|
|
command.ServiceType,
|
|
command.StartService = DateTime.Now,
|
|
command.EndService,
|
|
command.WorkshopId,
|
|
command.AccountId,
|
|
command.MaxPersonValid,
|
|
command.Amount,
|
|
command.Duration
|
|
);
|
|
|
|
_rollCallServiceRepository.Create(create);
|
|
_rollCallServiceRepository.SaveChanges();
|
|
|
|
return opration.Succcedded();
|
|
}
|
|
|
|
public OperationResult Upgrade(EditRollCallService command)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public OperationResult StopVipService(long serviceId)
|
|
{
|
|
var op = new OperationResult();
|
|
var vipService = _rollCallServiceRepository.Get(serviceId);
|
|
if (vipService == null)
|
|
return op.Failed("خطایی رخ داده است");
|
|
vipService.StopVipService();
|
|
_rollCallServiceRepository.SaveChanges();
|
|
return op.Succcedded();
|
|
}
|
|
|
|
public EditRollCallService GetDetails(long id)
|
|
{
|
|
return _rollCallServiceRepository.GetDetails(id);
|
|
}
|
|
|
|
public RollCallServiceViewModel GetActiveServiceByWorkshopId(long workshopId)
|
|
{
|
|
return _rollCallServiceRepository.GetActiveServiceByWorkshopId(workshopId);
|
|
}
|
|
|
|
public List<RollCallServiceViewModel> GetAllServiceByWorkshopId(long workshopId)
|
|
{
|
|
return _rollCallServiceRepository.GetAllServiceByWorkshopId(workshopId);
|
|
}
|
|
|
|
public List<RollCallServiceViewModel> GetActiveServiceByAccountId(long accountId)
|
|
{
|
|
return _rollCallServiceRepository.GetActiveServiceByAccountId(accountId);
|
|
}
|
|
|
|
public List<RollCallServiceViewModel> GetAllServiceByAccountId(long accountId)
|
|
{
|
|
return _rollCallServiceRepository.GetAllServiceByAccountId(accountId);
|
|
}
|
|
} |