Compare commits

..

3 Commits

Author SHA1 Message Date
18867b4929 set workshopId for FineController.cs 2026-01-13 11:10:48 +03:30
a9df0669c6 add client api FineController.cs 2026-01-13 11:08:03 +03:30
5c75316f40 add fine api client controller 2026-01-13 10:50:53 +03:30
14 changed files with 139 additions and 218 deletions

View File

@@ -8,6 +8,7 @@ public class CreateSalaryAidViewModel
public long WorkshopId { get; set; } public long WorkshopId { get; set; }
public string Amount { get; set; } public string Amount { get; set; }
public string SalaryDateTime { get; set; } public string SalaryDateTime { get; set; }
public string CalculationDateTime { get; set; }
public string NationalCode { get; set; } public string NationalCode { get; set; }
public int CalculationMonth { get; set; } public int CalculationMonth { get; set; }
public int CalculationYear { get; set; } public int CalculationYear { get; set; }

View File

@@ -8,7 +8,7 @@ public class SalaryAidGroupedByDateViewModel
public string YearFa { get; set; } public string YearFa { get; set; }
public int Month { get; set; } public int Month { get; set; }
public int Year { get; set; } public int Year { get; set; }
public List<SalaryAidGroupedByDateViewModelItems> Items { get; set; } public List<SalaryAidGroupedByDateViewModelItems> SalaryAidViewModels { get; set; }
public string TotalAmount { get; set; } public string TotalAmount { get; set; }
} }

View File

@@ -6,7 +6,7 @@ public class SalaryAidGroupedByEmployeeViewModel
{ {
public string EmployeeName { get; set; } public string EmployeeName { get; set; }
public long EmployeeId { get; set; } public long EmployeeId { get; set; }
public List<SalaryAidGroupedByEmployeeViewModelItems> Items { get; set; } public List<SalaryAidGroupedByEmployeeViewModelItems> SalaryAidViewModels { get; set; }
public string TotalAmount { get; set; } public string TotalAmount { get; set; }
} }

View File

@@ -3,15 +3,15 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using _0_Framework.Application;
namespace CompanyManagment.App.Contracts.SalaryAid; namespace CompanyManagment.App.Contracts.SalaryAid;
public class SalaryAidSearchViewModel:PaginationRequest public class SalaryAidSearchViewModel
{ {
public string StartDate { get; set; } public string StartDate { get; set; }
public string EndDate { get; set; } public string EndDate { get; set; }
public long EmployeeId { get; set; } public long EmployeeId { get; set; }
public long WorkshopId { get; set; } public long WorkshopId { get; set; }
public int PageIndex { get; set; }
public bool ShowAsGrouped { get; set; } public bool ShowAsGrouped { get; set; }
} }

View File

@@ -1,6 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Security.Cryptography; using System.Security.Cryptography;
using _0_Framework.Application;
namespace CompanyManagment.App.Contracts.SalaryAid; namespace CompanyManagment.App.Contracts.SalaryAid;
@@ -8,7 +7,7 @@ public class SalaryAidsGroupedViewModel
{ {
public List<SalaryAidGroupedByEmployeeViewModel> GroupedByEmployee { get; set; } public List<SalaryAidGroupedByEmployeeViewModel> GroupedByEmployee { get; set; }
public List<SalaryAidGroupedByDateViewModel> GroupedByDate { get; set; } public List<SalaryAidGroupedByDateViewModel> GroupedByDate { get; set; }
public PagedResult<SalaryAidViewModel> List { get; set; } public List<SalaryAidViewModel> SalaryAidListViewModels { get; set; }
} }

View File

@@ -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);
} }
} }

View File

@@ -146,7 +146,7 @@ public class SalaryAidRepository : RepositoryBase<long, SalaryAid>, ISalaryAidRe
{ {
YearFa = x.Key.YearFa, YearFa = x.Key.YearFa,
MonthFa = x.Key.MonthFa, MonthFa = x.Key.MonthFa,
Items = x.Select(s => new SalaryAidGroupedByDateViewModelItems() SalaryAidViewModels = x.Select(s => new SalaryAidGroupedByDateViewModelItems()
{ {
Amount = s.Amount, Amount = s.Amount,
EmployeeName = s.EmployeeFullName, EmployeeName = s.EmployeeFullName,
@@ -175,7 +175,7 @@ public class SalaryAidRepository : RepositoryBase<long, SalaryAid>, ISalaryAidRe
EmployeeId = x.Key, EmployeeId = x.Key,
TotalAmount = x.Sum(s => s.Amount).ToMoney(), TotalAmount = x.Sum(s => s.Amount).ToMoney(),
EmployeeName = employees.FirstOrDefault(e => e.id == x.Key).FullName, EmployeeName = employees.FirstOrDefault(e => e.id == x.Key).FullName,
Items = x.Select(s => new SalaryAidGroupedByEmployeeViewModelItems() SalaryAidViewModels = x.Select(s => new SalaryAidGroupedByEmployeeViewModelItems()
{ {
Amount = s.Amount.ToMoney(), Amount = s.Amount.ToMoney(),
Id = s.id, Id = s.id,
@@ -197,28 +197,23 @@ public class SalaryAidRepository : RepositoryBase<long, SalaryAid>, ISalaryAidRe
query = query.Where(x => x.SalaryAidDateTime >= startDate && x.SalaryAidDateTime <= endDate); query = query.Where(x => x.SalaryAidDateTime >= startDate && x.SalaryAidDateTime <= endDate);
} }
result.List = new PagedResult<SalaryAidViewModel>() result.SalaryAidListViewModels = query.OrderByDescending(x => x.SalaryAidDateTime).Skip(searchModel.PageIndex).Take(30).ToList().Select(
{ x => new SalaryAidViewModel()
TotalCount = query.Count(), {
List = query.OrderByDescending(x => x.SalaryAidDateTime).ApplyPagination(searchModel.PageIndex,searchModel.PageSize).ToList() Amount = x.Amount.ToMoney(),
.Select(x => new SalaryAidViewModel() CreationDate = x.CreationDate.ToFarsi(),
{ Id = x.id,
Amount = x.Amount.ToMoney(), EmployeeId = x.EmployeeId,
CreationDate = x.CreationDate.ToFarsi(), SalaryAidDateTimeFa = x.SalaryAidDateTime.ToFarsi(),
Id = x.id, SalaryAidDateTimeGe = x.SalaryAidDateTime,
EmployeeId = x.EmployeeId, WorkshopId = x.WorkshopId,
SalaryAidDateTimeFa = x.SalaryAidDateTime.ToFarsi(), YearFa = x.SalaryAidDateTime.ToFarsi().Substring(0, 4),
SalaryAidDateTimeGe = x.SalaryAidDateTime, MonthFa = x.SalaryAidDateTime.ToFarsi().Substring(5, 2),
WorkshopId = x.WorkshopId, PersonnelCode = personnelCodes.FirstOrDefault(p => p.EmployeeId == x.EmployeeId).PersonnelCode.ToString(),
YearFa = x.SalaryAidDateTime.ToFarsi().Substring(0, 4), EmployeeFullName = employees.FirstOrDefault(e => e.id == x.EmployeeId).FullName,
MonthFa = x.SalaryAidDateTime.ToFarsi().Substring(5, 2), AmountDouble = x.Amount,
PersonnelCode = personnelCodes.FirstOrDefault(p => p.EmployeeId == x.EmployeeId).PersonnelCode }).ToList();
.ToString(),
EmployeeFullName = employees.FirstOrDefault(e => e.id == x.EmployeeId).FullName,
AmountDouble = x.Amount,
}).ToList()
};
return result; return result;
} }

View File

@@ -209,38 +209,22 @@ public class CreateOrEditCheckoutCommandHandler : IBaseCommandHandler<CreateOrEd
} }
} }
////حقوق نهایی //حقوق نهایی
//var monthlySalaryPay = (totalHoursWorked * monthlySalaryDefined) / mandatoryHours; var monthlySalaryPay = (totalHoursWorked * monthlySalaryDefined) / mandatoryHours;
//// اگر اضافه کار داشت حقوق تعین شده به عنوان حقوق نهایی در نظر گرفته میشود // اگر اضافه کار داشت حقوق تعین شده به عنوان حقوق نهایی در نظر گرفته میشود
//monthlySalaryPay = monthlySalaryPay > monthlySalaryDefined ? monthlySalaryDefined : monthlySalaryPay; monthlySalaryPay = monthlySalaryPay > monthlySalaryDefined ? monthlySalaryDefined : monthlySalaryPay;
////حقوق کسر شده //حقوق کسر شده
//var deductionFromSalary = monthlySalaryDefined - monthlySalaryPay; var deductionFromSalary = monthlySalaryDefined - monthlySalaryPay;
//new chang salary compute
var monthlySalaryPay = totalHoursWorked * monthlySalaryDefined;
//زمان باقی مانده //زمان باقی مانده
var remainingTime = totalHoursWorked - mandatoryHours; var remainingTime = totalHoursWorked - mandatoryHours;
//تناسب به دقیقه
#region MyRegion
//var monthlySalaryDefinedTest = monthlySalaryDefined * mandatoryHours;
//var monthlySalaryPayTest = totalHoursWorked * monthlySalaryDefined;
////// اگر اضافه کار داشت حقوق تعین شده به عنوان حقوق نهایی در نظر گرفته میشود
//monthlySalaryPayTest = monthlySalaryPayTest > monthlySalaryDefinedTest ? monthlySalaryDefinedTest : monthlySalaryPayTest;
//////حقوق کسر شده
//var deductionFromSalaryTest = monthlySalaryDefinedTest - monthlySalaryPayTest;
#endregion
var computeResult = new ComputeResultDto var computeResult = new ComputeResultDto
{ {
MandatoryHours = mandatoryHours, MandatoryHours = mandatoryHours,
MonthlySalaryPay = monthlySalaryPay, MonthlySalaryPay = monthlySalaryPay,
DeductionFromSalary = 0 /*deductionFromSalary*/, DeductionFromSalary = deductionFromSalary,
RemainingHours = remainingTime RemainingHours = remainingTime
}; };
Console.WriteLine(mandatoryHours); Console.WriteLine(mandatoryHours);

View File

@@ -1,11 +1,10 @@
using DNTPersianUtils.Core; using GozareshgirProgramManager.Application._Common.Interfaces;
using GozareshgirProgramManager.Application._Common.Interfaces;
using GozareshgirProgramManager.Application._Common.Models; using GozareshgirProgramManager.Application._Common.Models;
using GozareshgirProgramManager.Application.Modules.SalaryPaymentSettings.Queries.GetUserListWhoHaveSettings; using GozareshgirProgramManager.Application.Modules.SalaryPaymentSettings.Queries.GetUserListWhoHaveSettings;
using GozareshgirProgramManager.Domain._Common; using GozareshgirProgramManager.Domain._Common;
using GozareshgirProgramManager.Domain.CheckoutAgg.Enums; using GozareshgirProgramManager.Domain.CheckoutAgg.Enums;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using PersianDateTime = PersianTools.Core.PersianDateTime; using PersianTools.Core;
namespace GozareshgirProgramManager.Application.Modules.Checkouts.Queries.GetUserToGropCreate; namespace GozareshgirProgramManager.Application.Modules.Checkouts.Queries.GetUserToGropCreate;
@@ -46,8 +45,8 @@ public class GetUserToGroupCreatingQueryHandler : IBaseQueryHandler<GetUserToGro
"ایجاد فیش فقط برای ماه های گذشته امکان پذیر است"); "ایجاد فیش فقط برای ماه های گذشته امکان پذیر است");
//var lastMonthStart = lastMonth; var lastMonthStart = lastMonth;
var lastMonthEnd = ((selectedDate.ToFarsi().FindeEndOfMonth())).ToGeorgianDateTime(); var lastMonthEnd = lastMonth;
var query = var query =
await (from u in _context.Users await (from u in _context.Users
@@ -61,8 +60,8 @@ public class GetUserToGroupCreatingQueryHandler : IBaseQueryHandler<GetUserToGro
// LEFT JOIN // LEFT JOIN
//فیش //فیش
join ch in _context.Checkouts join ch in _context.Checkouts
.Where(x => x.CheckoutStartDate < lastMonthEnd .Where(x => x.CheckoutStartDate < lastMonthStart
&& x.CheckoutEndDate > selectedDate) && x.CheckoutEndDate >= lastMonthStart)
on u.Id equals ch.UserId into chJoin on u.Id equals ch.UserId into chJoin
from ch in chJoin.DefaultIfEmpty() from ch in chJoin.DefaultIfEmpty()

View File

@@ -56,7 +56,6 @@ public class ProjectSetTimeDetailsQueryHandler
var skills = await _context.Skills var skills = await _context.Skills
.AsNoTracking() .AsNoTracking()
.OrderBy(x=>x.CreationDate)
.ToListAsync(cancellationToken); .ToListAsync(cancellationToken);
var res = new ProjectSetTimeResponse( var res = new ProjectSetTimeResponse(
@@ -85,7 +84,7 @@ public class ProjectSetTimeDetailsQueryHandler
UserId = section?.OriginalAssignedUserId ?? 0, UserId = section?.OriginalAssignedUserId ?? 0,
SkillId = skill.Id, SkillId = skill.Id,
}; };
}).ToList(), }).OrderBy(x => x.SkillId).ToList(),
task.Id, task.Id,
level); level);
@@ -115,7 +114,6 @@ public class ProjectSetTimeDetailsQueryHandler
var skills = await _context.Skills var skills = await _context.Skills
.AsNoTracking() .AsNoTracking()
.OrderBy(x=>x.CreationDate)
.ToListAsync(cancellationToken); .ToListAsync(cancellationToken);
var res = new ProjectSetTimeResponse( var res = new ProjectSetTimeResponse(
@@ -137,7 +135,7 @@ public class ProjectSetTimeDetailsQueryHandler
UserId = section?.UserId ?? 0, UserId = section?.UserId ?? 0,
SkillId = skill.Id, SkillId = skill.Id,
}; };
}).ToList(), }).OrderBy(x => x.SkillId).ToList(),
phase.Id, phase.Id,
level); level);
@@ -167,7 +165,6 @@ public class ProjectSetTimeDetailsQueryHandler
var skills = await _context.Skills var skills = await _context.Skills
.AsNoTracking() .AsNoTracking()
.OrderBy(x=>x.CreationDate)
.ToListAsync(cancellationToken); .ToListAsync(cancellationToken);
var res = new ProjectSetTimeResponse( var res = new ProjectSetTimeResponse(
@@ -189,7 +186,7 @@ public class ProjectSetTimeDetailsQueryHandler
UserId = section?.UserId ?? 0, UserId = section?.UserId ?? 0,
SkillId = skill.Id, SkillId = skill.Id,
}; };
}).ToList(), }).OrderBy(x => x.SkillId).ToList(),
project.Id, project.Id,
level); level);

View File

@@ -1,15 +1,12 @@
using GozareshgirProgramManager.Application._Common.Interfaces; using GozareshgirProgramManager.Application._Common.Interfaces;
using GozareshgirProgramManager.Application._Common.Models; using GozareshgirProgramManager.Application._Common.Models;
using GozareshgirProgramManager.Application.Modules.TaskChat.DTOs; using GozareshgirProgramManager.Application.Modules.TaskChat.DTOs;
using GozareshgirProgramManager.Domain.TaskChatAgg.Enums;
using MediatR;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace GozareshgirProgramManager.Application.Modules.TaskChat.Queries.GetMessages; namespace GozareshgirProgramManager.Application.Modules.TaskChat.Queries.GetMessages;
public record GetMessagesQuery( public record GetMessagesQuery(
Guid TaskId, Guid TaskId,
MessageType? MessageType,
int Page = 1, int Page = 1,
int PageSize = 50 int PageSize = 50
) : IBaseQuery<PaginationResult<MessageDto>>; ) : IBaseQuery<PaginationResult<MessageDto>>;
@@ -69,12 +66,7 @@ public class GetMessagesQueryHandler : IBaseQueryHandler<GetMessagesQuery, Pagin
var query = _context.TaskChatMessages var query = _context.TaskChatMessages
.Where(m => m.TaskId == request.TaskId && !m.IsDeleted) .Where(m => m.TaskId == request.TaskId && !m.IsDeleted)
.Include(m => m.ReplyToMessage) .Include(m => m.ReplyToMessage)
.OrderBy(m => m.CreationDate).AsQueryable(); .OrderBy(m => m.CreationDate);
if (request.MessageType.HasValue)
{
query = query.Where(m => m.MessageType == request.MessageType.Value);
}
var totalCount = await query.CountAsync(cancellationToken); var totalCount = await query.CountAsync(cancellationToken);

View File

@@ -8,7 +8,6 @@ using GozareshgirProgramManager.Application.Modules.TaskChat.DTOs;
using GozareshgirProgramManager.Application.Modules.TaskChat.Queries.GetMessages; using GozareshgirProgramManager.Application.Modules.TaskChat.Queries.GetMessages;
using GozareshgirProgramManager.Application.Modules.TaskChat.Queries.GetPinnedMessages; using GozareshgirProgramManager.Application.Modules.TaskChat.Queries.GetPinnedMessages;
using GozareshgirProgramManager.Application.Modules.TaskChat.Queries.SearchMessages; using GozareshgirProgramManager.Application.Modules.TaskChat.Queries.SearchMessages;
using GozareshgirProgramManager.Domain.TaskChatAgg.Enums;
using MediatR; using MediatR;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using ServiceHost.BaseControllers; using ServiceHost.BaseControllers;
@@ -31,17 +30,15 @@ public class TaskChatController : ProgramManagerBaseController
/// دریافت لیست پیام‌های یک تسک /// دریافت لیست پیام‌های یک تسک
/// </summary> /// </summary>
/// <param name="taskId">شناسه تسک</param> /// <param name="taskId">شناسه تسک</param>
/// <param name="messageType">نوع پیام</param>
/// <param name="page">صفحه (پیش‌فرض: 1)</param> /// <param name="page">صفحه (پیش‌فرض: 1)</param>
/// <param name="pageSize">تعداد در هر صفحه (پیش‌فرض: 50)</param> /// <param name="pageSize">تعداد در هر صفحه (پیش‌فرض: 50)</param>
[HttpGet("{taskId:guid}/messages")] [HttpGet("{taskId:guid}/messages")]
public async Task<ActionResult<OperationResult<PaginationResult<MessageDto>>>> GetMessages( public async Task<ActionResult<OperationResult<PaginationResult<MessageDto>>>> GetMessages(
Guid taskId, Guid taskId,
[FromQuery] MessageType? messageType,
[FromQuery] int page = 1, [FromQuery] int page = 1,
[FromQuery] int pageSize = 50) [FromQuery] int pageSize = 50)
{ {
var query = new GetMessagesQuery(taskId,messageType, page, pageSize); var query = new GetMessagesQuery(taskId, page, pageSize);
var result = await _mediator.Send(query); var result = await _mediator.Send(query);
return result; return result;
} }

View File

@@ -0,0 +1,95 @@
using _0_Framework.Application;
using CompanyManagment.App.Contracts.Fine;
using CompanyManagment.App.Contracts.FineSubject;
using Microsoft.AspNetCore.Mvc;
using ServiceHost.BaseControllers;
namespace ServiceHost.Areas.Client.Controllers;
public class FineController:ClientBaseController
{
private readonly IFineApplication _fineApplication;
private readonly IFineSubjectApplication _fineSubjectApplication;
private readonly long _workshopId;
public FineController(IFineApplication fineApplication, IFineSubjectApplication fineSubjectApplication,
IAuthHelper authHelper)
{
_fineApplication = fineApplication;
_fineSubjectApplication = fineSubjectApplication;
_workshopId = authHelper.GetWorkshopId();
}
[HttpGet]
public ActionResult<FinesGroupedViewModel> GetList([FromQuery]FineSearchViewModel searchModel)
{
searchModel.WorkshopId = _workshopId;
var res = _fineApplication.GetSearchListAsGrouped(searchModel);
return res;
}
[HttpPost]
public ActionResult<OperationResult> Create([FromBody]CreateFineViewModel command)
{
command.WorkshopId = _workshopId;
var res =_fineApplication.Create(command);
return res;
}
[HttpPut]
public ActionResult<OperationResult> Edit([FromBody]EditFineViewModel command)
{
command.WorkshopId = _workshopId;
var res = _fineApplication.Edit(command);
return res;
}
[HttpGet("{id:long}")]
public ActionResult<EditFineViewModel> Details(long id)
{
var res = _fineApplication.GetDetails(id);
return res;
}
[HttpDelete(("{id:long}"))]
public ActionResult<OperationResult> Remove(long id)
{
var res = _fineApplication.Remove(id);
return res;
}
#region FineSubject
[HttpGet("subject")]
public ActionResult<List<FineSubjectViewModel>> GetList()
{
var res = _fineSubjectApplication.GetAll(_workshopId);
return res;
}
[HttpPost("subject/{id:long}")]
public ActionResult<OperationResult> CreateSubject(CreateFineSubjectViewModel command)
{
command.WorkshopId = _workshopId;
var res = _fineSubjectApplication.Create(command);
return res;
}
[HttpPut("subject/{id:long}")]
public ActionResult<OperationResult> EditSubject(EditFineSubjectViewModel command)
{
command.WorkshopId = _workshopId;
var res = _fineSubjectApplication.Edit(command);
return res;
}
[HttpDelete("subject/{id:long}")]
public ActionResult<OperationResult> RemoveSubject(long id)
{
var res = _fineSubjectApplication.Delete(id);
return res;
}
#endregion
}

View File

@@ -1,138 +0,0 @@
using _0_Framework.Application;
using CompanyManagement.Infrastructure.Excel.SalaryAid;
using CompanyManagment.App.Contracts.SalaryAid;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Build.Evaluation;
using ServiceHost.BaseControllers;
namespace ServiceHost.Areas.Client.Controllers;
public class SalaryAidController:ClientBaseController
{
private readonly ISalaryAidApplication _salaryAidApplication;
private readonly long _workshopId;
private readonly SalaryAidImportExcel _salaryAidImportExcel;
public SalaryAidController(ISalaryAidApplication salaryAidApplication,IAuthHelper authHelper, SalaryAidImportExcel salaryAidImportExcel)
{
_salaryAidApplication = salaryAidApplication;
_salaryAidImportExcel = salaryAidImportExcel;
_workshopId = authHelper.GetWorkshopId();
}
[HttpGet]
public ActionResult<SalaryAidsGroupedViewModel> GetList([FromQuery]SalaryAidSearchViewModel searchModel)
{
searchModel.WorkshopId = _workshopId;
var result = _salaryAidApplication.GetSearchListAsGrouped(searchModel);
return Ok(result);
}
[HttpPost]
public ActionResult<OperationResult> Create([FromBody]CreateSalaryAidRequest request)
{
var command = new CreateSalaryAidViewModel()
{
Amount = request.Amount.ToMoney(),
CalculationMonth = request.CalculationMonth,
CalculationYear = request.CalculationYear,
EmployeeIds = request.EmployeeIds,
WorkshopId = _workshopId,
SalaryDateTime = request.SalaryDateTime,
};
var result = _salaryAidApplication.Create(command);
return result;
}
[HttpPut]
public ActionResult<OperationResult> Edit([FromBody]EditSalaryAidRequest request)
{
var command = new EditSalaryAidViewModel()
{
Id = request.Id,
Amount = request.Amount.ToMoney(),
CalculationMonth = request.CalculationMonth,
CalculationYear = request.CalculationYear,
SalaryDateTime = request.SalaryDateTime,
WorkshopId = _workshopId,
};
var result = _salaryAidApplication.Edit(command);
return result;
}
[HttpGet("{id}")]
public ActionResult<EditSalaryAidRequest> EditDetails(long id)
{
var data = _salaryAidApplication.GetDetails(id);
var res = new EditSalaryAidRequest()
{
Id = data.Id,
Amount = data.Amount.MoneyToDouble(),
CalculationMonth = data.CalculationMonth,
CalculationYear = data.CalculationYear,
SalaryDateTime = data.SalaryDateTime,
};
return res;
}
[HttpDelete("{id:long}")]
public ActionResult<OperationResult> Delete(long id)
{
var result = _salaryAidApplication.Remove(id);
return result;
}
[HttpPost("validate-excel")]
public ActionResult<ExcelValidation<SalaryAidImportData>> ValidateExcel([FromForm]ValidateExcelRequest request)
{
var validation = _salaryAidImportExcel.ReadAndValidateExcel(request.Excel, _workshopId);
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 IFormFile Excel { get; set; }
}
public class EditSalaryAidRequest
{
public long Id { get; set; }
public long EmployeeId { get; set; }
public double Amount { get; set; }
public string SalaryDateTime { get; set; }
public int CalculationMonth { get; set; }
public int CalculationYear { get; set; }
}
public class CreateSalaryAidRequest
{
public List<long> EmployeeIds { get; set; }
public double Amount { get; set; }
public string SalaryDateTime { get; set; }
public int CalculationMonth { get; set; }
public int CalculationYear { get; set; }
}