load data and create service percentage
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using CompanyManagment.App.Contracts.InstitutionPlan;
|
||||
using CompanyManagment.App.Contracts.TemporaryClientRegistration;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Company.Domain.InstitutionPlanAgg;
|
||||
|
||||
@@ -26,4 +27,10 @@ public interface IPlanPercentageRepository : IRepository<long, PlanPercentage>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
InstitutionPlanViewModel GetInstitutionPlanForWorkshop(WorkshopTempViewModel command);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت دیتای مودال ایجاد
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<CreateServiceAmountDto> GetCreateModalData();
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
namespace CompanyManagment.App.Contracts.InstitutionPlan;
|
||||
|
||||
public class CreateServiceAmountDto
|
||||
{
|
||||
/// <summary>
|
||||
/// آی دی
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// قرارداد و تصفیه
|
||||
/// درصد از مزد روزانه
|
||||
/// string
|
||||
/// </summary>
|
||||
public string ContractAndCheckoutPercentStr { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// بیمه
|
||||
/// درصد از مزد روزانه
|
||||
/// string
|
||||
/// </summary>
|
||||
public string InsurancePercentStr { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// حضورغباب
|
||||
/// درصد از مزد روزانه
|
||||
/// string
|
||||
/// </summary>
|
||||
public string RollCallPercentStr { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// فیش غیر رسمی
|
||||
/// درصد از مزد روزانه
|
||||
/// string
|
||||
/// </summary>
|
||||
public string CustomizeCheckoutPercentStr { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// خدمات حضوری قرداد و تصفیه
|
||||
/// درصد از مزد روزانه
|
||||
/// string
|
||||
/// </summary>
|
||||
public string ContractAndCheckoutInPersonPercentStr { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// خدمات حضوری بیمه
|
||||
/// درصد از مزد روزانه
|
||||
/// string
|
||||
/// </summary>
|
||||
public string InsuranceInPersonPercentStr { get; set; }
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application;
|
||||
using CompanyManagment.App.Contracts.TemporaryClientRegistration;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.InstitutionPlan;
|
||||
|
||||
@@ -34,4 +35,18 @@ public interface IInstitutionPlanApplication
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
InstitutionPlanViewModel GetInstitutionPlanForWorkshop(WorkshopTempViewModel command);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// دریافت دیتای درصد سرویس برای مودال ایجاد
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<CreateServiceAmountDto> GetCreateModalData();
|
||||
|
||||
/// <summary>
|
||||
/// ایجاد درصد سرویس
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
Task<OperationResult> CreateInstitutionPlanPercentage(CreateServiceAmountDto command);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using Company.Domain.InstitutionPlanAgg;
|
||||
using CompanyManagment.App.Contracts.InstitutionPlan;
|
||||
@@ -84,4 +85,68 @@ public class InstitutionPlanApplication : IInstitutionPlanApplication
|
||||
{
|
||||
return _planPercentageRepository.GetInstitutionPlanForWorkshop(command);
|
||||
}
|
||||
|
||||
|
||||
#region ForApi
|
||||
|
||||
public async Task<CreateServiceAmountDto> GetCreateModalData()
|
||||
{
|
||||
return await _planPercentageRepository.GetCreateModalData();
|
||||
}
|
||||
|
||||
|
||||
public async Task<OperationResult> CreateInstitutionPlanPercentage(CreateServiceAmountDto command)
|
||||
{
|
||||
var op = new OperationResult();
|
||||
if (string.IsNullOrWhiteSpace(command.ContractAndCheckoutInPersonPercentStr) || command.ContractAndCheckoutInPersonPercentStr == "0" ||
|
||||
string.IsNullOrWhiteSpace(command.ContractAndCheckoutPercentStr) || (command.ContractAndCheckoutPercentStr == "0" ||
|
||||
string.IsNullOrWhiteSpace(command.CustomizeCheckoutPercentStr) || command.CustomizeCheckoutPercentStr == "0" ||
|
||||
string.IsNullOrWhiteSpace(command.InsuranceInPersonPercentStr) || command.InsuranceInPersonPercentStr == "0" ||
|
||||
string.IsNullOrWhiteSpace(command.InsurancePercentStr) || command.InsurancePercentStr == "0" ||
|
||||
string.IsNullOrWhiteSpace(command.RollCallPercentStr) || command.RollCallPercentStr == "0"))
|
||||
return op.Failed("هیچ یک از فیلدها نمیتوانند صفر باشند");
|
||||
|
||||
int contractAndCheckoutInPersonPercent = 0;
|
||||
int contractAndCheckoutPercent = 0;
|
||||
int customizeCheckoutPercent = 0;
|
||||
int insuranceInPersonPercent = 0;
|
||||
int insurancePercent = 0;
|
||||
int rollCallPercent = 0;
|
||||
|
||||
try
|
||||
{
|
||||
contractAndCheckoutInPersonPercent = Convert.ToInt32(command.ContractAndCheckoutInPersonPercentStr);
|
||||
contractAndCheckoutPercent = Convert.ToInt32(command.ContractAndCheckoutPercentStr);
|
||||
customizeCheckoutPercent = Convert.ToInt32(command.CustomizeCheckoutPercentStr);
|
||||
insuranceInPersonPercent = Convert.ToInt32(command.InsuranceInPersonPercentStr);
|
||||
insurancePercent = Convert.ToInt32(command.InsurancePercentStr);
|
||||
rollCallPercent = Convert.ToInt32(command.RollCallPercentStr);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return op.Failed("لطفا عدد معتبر وارد کنید");
|
||||
|
||||
}
|
||||
|
||||
var firstPlan =await _planPercentageRepository.GetCreateModalData();
|
||||
if (firstPlan != null)
|
||||
{
|
||||
var planPercentage = _planPercentageRepository.Get(firstPlan.Id);
|
||||
planPercentage.Edit(contractAndCheckoutPercent, insurancePercent, rollCallPercent, customizeCheckoutPercent, contractAndCheckoutInPersonPercent, insuranceInPersonPercent);
|
||||
_planPercentageRepository.SaveChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
var create = new PlanPercentage(contractAndCheckoutPercent, insurancePercent, rollCallPercent,
|
||||
customizeCheckoutPercent, contractAndCheckoutInPersonPercent, insuranceInPersonPercent);
|
||||
await _planPercentageRepository.CreateAsync(create);
|
||||
await _planPercentageRepository.SaveChangesAsync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.InfraStructure;
|
||||
using Company.Domain.InstitutionPlanAgg;
|
||||
@@ -44,6 +45,7 @@ public class PlanPercentageRepository : RepositoryBase<long, PlanPercentage>, IP
|
||||
}).FirstOrDefault();
|
||||
}
|
||||
|
||||
|
||||
public List<InstitutionPlanViewModel> GetInstitutionPlanList(int pageIndex, int countPeron)
|
||||
{
|
||||
var planPercentage = _context.PlanPercentages.FirstOrDefault();
|
||||
@@ -303,4 +305,23 @@ public class PlanPercentageRepository : RepositoryBase<long, PlanPercentage>, IP
|
||||
|
||||
return new InstitutionPlanViewModel();
|
||||
}
|
||||
|
||||
|
||||
#region ForApi
|
||||
|
||||
public async Task<CreateServiceAmountDto> GetCreateModalData()
|
||||
{
|
||||
return await _context.PlanPercentages.Select(x => new CreateServiceAmountDto()
|
||||
{
|
||||
Id = x.id,
|
||||
ContractAndCheckoutInPersonPercentStr = $"{x.ContractAndCheckoutInPersonPercent}",
|
||||
CustomizeCheckoutPercentStr = $"{x.CustomizeCheckoutPercent}",
|
||||
ContractAndCheckoutPercentStr = $"{x.ContractAndCheckoutPercent}",
|
||||
InsuranceInPersonPercentStr = $"{x.InsuranceInPersonPercent}",
|
||||
InsurancePercentStr = $"{x.InsurancePercent}",
|
||||
RollCallPercentStr = $"{x.RollCallPercent}",
|
||||
}).FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using _0_Framework.Application;
|
||||
using AccountManagement.Application.Contracts.Ticket;
|
||||
using CompanyManagment.App.Contracts.InstitutionPlan;
|
||||
using CompanyManagment.App.Contracts.Workshop;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ServiceHost.BaseControllers;
|
||||
|
||||
namespace ServiceHost.Areas.Admin.Controllers;
|
||||
|
||||
public class ServiceAmountsManagement : AdminBaseController
|
||||
{
|
||||
private readonly IInstitutionPlanApplication _institutionPlanApplication;
|
||||
private readonly IAuthHelper _authHelper;
|
||||
|
||||
public ServiceAmountsManagement(IInstitutionPlanApplication institutionPlanApplication, IAuthHelper authHelper)
|
||||
{
|
||||
_institutionPlanApplication = institutionPlanApplication;
|
||||
_authHelper = authHelper;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// دریافت دیتای مودال ایجاد
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("GetCreateModalData")]
|
||||
public async Task<ActionResult<CreateServiceAmountDto>> GetCreateModalData()
|
||||
{
|
||||
if(!_authHelper.HasPermission(315))
|
||||
return Forbid();
|
||||
var data = await _institutionPlanApplication.GetCreateModalData();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ذخیره درصدها
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("CreateServicePercentage")]
|
||||
public async Task<ActionResult<OperationResult>> CreateServicePercentage([FromBody] CreateServiceAmountDto command)
|
||||
{
|
||||
|
||||
if (!_authHelper.HasPermission(315))
|
||||
return new OperationResult().Failed("اجازه دسترسی ندارید");
|
||||
|
||||
var result = await _institutionPlanApplication.CreateInstitutionPlanPercentage(command);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user