87 lines
3.8 KiB
C#
87 lines
3.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using System.Threading.Tasks;
|
|
using _0_Framework.Application;
|
|
using Company.Domain.GroupPlanAgg;
|
|
using Company.Domain.GroupPlanJobItemAgg;
|
|
using Company.Domain.JobAgg;
|
|
using Company.Domain.WorkshopPlanAgg;
|
|
using Company.Domain.WorkshopPlanEmployeeAgg;
|
|
using CompanyManagment.App.Contracts.EmployeeChildren;
|
|
using CompanyManagment.App.Contracts.GroupPlan;
|
|
using CompanyManagment.App.Contracts.GroupPlanJobItem;
|
|
using CompanyManagment.App.Contracts.WorkshopPlan;
|
|
|
|
namespace CompanyManagment.Application;
|
|
|
|
public class WorkshopPlanApplication : IWorkshopPlanApplication
|
|
{
|
|
private readonly IWorkshopPlanRepository _workshopPlanRepository;
|
|
private readonly IGroupPlanRepository _groupPlanRepository;
|
|
private readonly IGroupPlanJobItemRepository _groupPlanJobItemRepository;
|
|
private readonly IJobRepository _jobRepository;
|
|
private readonly IWorkshopPlanEmployeeRepository _workshopPlanEmployeeRepository;
|
|
|
|
public WorkshopPlanApplication(IWorkshopPlanRepository workshopPlanRepository, IGroupPlanRepository groupPlanRepository, IGroupPlanJobItemRepository groupPlanJobItemRepository, IJobRepository jobRepository, IWorkshopPlanEmployeeRepository workshopPlanEmployeeRepository)
|
|
{
|
|
_workshopPlanRepository = workshopPlanRepository;
|
|
_groupPlanRepository = groupPlanRepository;
|
|
_groupPlanJobItemRepository = groupPlanJobItemRepository;
|
|
_jobRepository = jobRepository;
|
|
_workshopPlanEmployeeRepository = workshopPlanEmployeeRepository;
|
|
}
|
|
|
|
public EditWorkshopPlan GetWorkshopPlanByWorkshopId(long workshopId)
|
|
{
|
|
return _workshopPlanRepository.GetWorkshopPlanByWorkshopId(workshopId);
|
|
}
|
|
|
|
public OperationResult CreateWorkshopPlan(CreateWorkshopPlan command)
|
|
{
|
|
var opration = new OperationResult();
|
|
|
|
|
|
var createWorkshopPlan = new WorkshopPlan(command.ExecutionDateFa, command.IncludingDateFa, command.Designer,
|
|
command.DesignerPhone, command.WorkshopId);
|
|
_workshopPlanRepository.Create(createWorkshopPlan);
|
|
_workshopPlanRepository.SaveChanges();
|
|
|
|
for (int i = 0; i <= command.EditGroupPlanlist.Count - 1; i++)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(command.EditGroupPlanlist[i].AnnualSalaryStr)
|
|
&& !string.IsNullOrWhiteSpace(command.EditGroupPlanlist[i].BaseSalaryStr)
|
|
&& !string.IsNullOrWhiteSpace(command.EditGroupPlanlist[i].JobSalaryStr)
|
|
&& command.EditGroupPlanlist[i].JobIdList.Count >0)
|
|
{
|
|
var jobSalary = command.EditGroupPlanlist[i].JobSalaryStr.MoneyToDouble();
|
|
var annualSalary = command.EditGroupPlanlist[i].AnnualSalaryStr.MoneyToDouble();
|
|
var baseSalary = command.EditGroupPlanlist[i].BaseSalaryStr.MoneyToDouble();
|
|
var group = new GroupPlan(command.EditGroupPlanlist[i].GroupNo, jobSalary, annualSalary, baseSalary,command.WorkshopId, createWorkshopPlan.id);
|
|
_groupPlanRepository.Create(group);
|
|
_groupPlanRepository.SaveChanges();
|
|
|
|
foreach (var jobId in command.EditGroupPlanlist[i].JobIdList)
|
|
{
|
|
var job = _jobRepository.GetDetails(jobId);
|
|
|
|
var groupPlanjob = new GroupPlanJobItem(jobId, group.id, createWorkshopPlan.id, command.WorkshopId,
|
|
command.EditGroupPlanlist[i].GroupNo, job.JobName);
|
|
_groupPlanJobItemRepository.Create(groupPlanjob);
|
|
_groupPlanJobItemRepository.SaveChanges();
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return opration.Succcedded();
|
|
|
|
|
|
throw new NotImplementedException();
|
|
}
|
|
} |