99 lines
3.3 KiB
C#
99 lines
3.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using _0_Framework.Application;
|
|
using Company.Domain.RollCallAgg;
|
|
using CompanyManagment.App.Contracts.Employee;
|
|
using CompanyManagment.App.Contracts.RollCall;
|
|
|
|
namespace CompanyManagment.Application;
|
|
|
|
public class RollCallApplication : IRollCallApplication
|
|
{
|
|
private readonly IRollCallRepository _rollCallRepository;
|
|
private readonly IEmployeeApplication _employeeApplication;
|
|
|
|
public RollCallApplication(IRollCallRepository rollCallRepository, IEmployeeApplication employeeApplication)
|
|
{
|
|
_rollCallRepository = rollCallRepository;
|
|
_employeeApplication = employeeApplication;
|
|
}
|
|
|
|
public OperationResult Create(CreateRollCall command)
|
|
{
|
|
var opration = new OperationResult();
|
|
var startDateFa = command.StartDate.ToFarsi();
|
|
|
|
var yearFa = Convert.ToInt32(startDateFa.Substring(0, 4));
|
|
var monthFa = Convert.ToInt32(startDateFa.Substring(5, 2));
|
|
var employeeName = _employeeApplication.GetDetails(command.EmployeeId).EmployeeFullName;
|
|
var create = new RollCall(command.WorkshopId, command.EmployeeId, employeeName, command.StartDate, null,
|
|
yearFa, monthFa);
|
|
_rollCallRepository.Create(create);
|
|
_rollCallRepository.SaveChanges();
|
|
return opration.Succcedded();
|
|
}
|
|
|
|
public OperationResult Edit(long id)
|
|
{
|
|
var opration = new OperationResult();
|
|
var personRollCall = _rollCallRepository.Get(id);
|
|
if (personRollCall == null)
|
|
opration.Failed("رکورد مورد نظر وجود ندارد");
|
|
var now = DateTime.Now;
|
|
personRollCall.Edit(now);
|
|
_rollCallRepository.SaveChanges();
|
|
return opration.Succcedded();
|
|
}
|
|
|
|
public EditRollCall GetByEmployeeIdAndWorkshopId(long employeeId, long workshopId)
|
|
{
|
|
return _rollCallRepository.GetByEmployeeIdAndWorkshopId(employeeId, workshopId);
|
|
}
|
|
|
|
public List<CheckoutDailyRollCallViewModel> GetActiveEmployeeRollCallsForDuration(long employeeId, long workshopId, DateTime startDate, DateTime endDate)
|
|
{
|
|
|
|
if (startDate >= endDate)
|
|
return new();
|
|
|
|
return _rollCallRepository.GetEmployeeRollCallsForDuration(employeeId, workshopId, startDate, endDate);
|
|
}
|
|
|
|
public EditRollCall GetById(long id)
|
|
{
|
|
return _rollCallRepository.GetById(id);
|
|
}
|
|
|
|
public List<RollCallViewModel> Search(RollCallSearchModel searchModel)
|
|
{
|
|
return _rollCallRepository.Search(searchModel);
|
|
}
|
|
|
|
public List<RollCallViewModel> GetCurrentDay(RollCallSearchModel searchModel)
|
|
{
|
|
return _rollCallRepository.GetCurrentDay(searchModel);
|
|
}
|
|
|
|
public List<RollCallViewModel> GetHistoryCase(RollCallSearchModel searchModel)
|
|
{
|
|
return _rollCallRepository.GetCurrentDay(searchModel);
|
|
}
|
|
|
|
public CurrentDayRollCall GetWorkshopCurrentDayRollCalls(long workshopId)
|
|
{
|
|
return _rollCallRepository.GetWorkshopCurrentDayRollCalls(workshopId);
|
|
}
|
|
|
|
public RollCallsByDateViewModel GetWorkshopRollCallHistory(RollCallSearchModel searchModel)
|
|
{
|
|
return _rollCallRepository.GetWorkshopRollCallHistory(searchModel);
|
|
}
|
|
|
|
public long Flag(long employeeId, long workshopId)
|
|
{
|
|
return _rollCallRepository.Flag(employeeId, workshopId);
|
|
}
|
|
} |