add OnPostCreateFromExcelData method to SalaryAidController for bulk salary aid creation from Excel data
This commit is contained in:
@@ -433,7 +433,7 @@ public class SalaryAidApplication : ISalaryAidApplication
|
|||||||
var checkouts = _checkoutRepository.GetByWorkshopIdEmployeeIdInDate(
|
var checkouts = _checkoutRepository.GetByWorkshopIdEmployeeIdInDate(
|
||||||
command.WorkshopId, employeeId, calculationDateGr).GetAwaiter().GetResult();
|
command.WorkshopId, employeeId, calculationDateGr).GetAwaiter().GetResult();
|
||||||
|
|
||||||
checkouts?.SetAmountConflict(true);
|
checkouts?.SetAmountConflict(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using _0_Framework.Application;
|
|||||||
using CompanyManagement.Infrastructure.Excel.SalaryAid;
|
using CompanyManagement.Infrastructure.Excel.SalaryAid;
|
||||||
using CompanyManagment.App.Contracts.SalaryAid;
|
using CompanyManagment.App.Contracts.SalaryAid;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.Build.Evaluation;
|
||||||
using ServiceHost.BaseControllers;
|
using ServiceHost.BaseControllers;
|
||||||
|
|
||||||
namespace ServiceHost.Areas.Client.Controllers;
|
namespace ServiceHost.Areas.Client.Controllers;
|
||||||
@@ -60,7 +61,7 @@ public class SalaryAidController:ClientBaseController
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("edit")]
|
[HttpGet("{id}")]
|
||||||
public ActionResult<EditSalaryAidRequest> EditDetails(long id)
|
public ActionResult<EditSalaryAidRequest> EditDetails(long id)
|
||||||
{
|
{
|
||||||
var data = _salaryAidApplication.GetDetails(id);
|
var data = _salaryAidApplication.GetDetails(id);
|
||||||
@@ -88,6 +89,28 @@ public class SalaryAidController:ClientBaseController
|
|||||||
|
|
||||||
return validation;
|
return validation;
|
||||||
}
|
}
|
||||||
|
[HttpPost("create-from-excel")]
|
||||||
|
public async Task<ActionResult<OperationResult>> OnPostCreateFromExcelData(List<SalaryAidImportData> data)
|
||||||
|
{
|
||||||
|
var commands = data.Select(x => new CreateSalaryAidViewModel()
|
||||||
|
{
|
||||||
|
WorkshopId = x.WorkshopId,
|
||||||
|
Amount = x.Amount.ToMoney(),
|
||||||
|
EmployeeIds = [x.EmployeeId],
|
||||||
|
SalaryDateTime = x.SalaryAidDateTime,
|
||||||
|
NationalCode = x.NationalCode,
|
||||||
|
CalculationMonth = x.calculationMonth,
|
||||||
|
CalculationYear = x.calculationYear
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
OperationResult result = await _salaryAidApplication.CreateRangeAsync(commands);
|
||||||
|
|
||||||
|
return new JsonResult(new
|
||||||
|
{
|
||||||
|
result.IsSuccedded,
|
||||||
|
result.Message
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ValidateExcelRequest
|
public class ValidateExcelRequest
|
||||||
|
|||||||
Reference in New Issue
Block a user