add Excel validation for salary aid import and update pagination in salary aid list
This commit is contained in:
@@ -3,15 +3,15 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.SalaryAid;
|
||||
public class SalaryAidSearchViewModel
|
||||
public class SalaryAidSearchViewModel:PaginationRequest
|
||||
{
|
||||
public string StartDate { get; set; }
|
||||
public string EndDate { get; set; }
|
||||
public long EmployeeId { get; set; }
|
||||
public long WorkshopId { get; set; }
|
||||
public int PageIndex { get; set; }
|
||||
public bool ShowAsGrouped { get; set; }
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Cryptography;
|
||||
using _0_Framework.Application;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.SalaryAid;
|
||||
|
||||
@@ -7,7 +8,7 @@ public class SalaryAidsGroupedViewModel
|
||||
{
|
||||
public List<SalaryAidGroupedByEmployeeViewModel> GroupedByEmployee { get; set; }
|
||||
public List<SalaryAidGroupedByDateViewModel> GroupedByDate { get; set; }
|
||||
public List<SalaryAidViewModel> SalaryAidListViewModels { get; set; }
|
||||
public PagedResult<SalaryAidViewModel> SalaryAidListViewModels { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -197,8 +197,11 @@ public class SalaryAidRepository : RepositoryBase<long, SalaryAid>, ISalaryAidRe
|
||||
query = query.Where(x => x.SalaryAidDateTime >= startDate && x.SalaryAidDateTime <= endDate);
|
||||
}
|
||||
|
||||
result.SalaryAidListViewModels = query.OrderByDescending(x => x.SalaryAidDateTime).Skip(searchModel.PageIndex).Take(30).ToList().Select(
|
||||
x => new SalaryAidViewModel()
|
||||
result.SalaryAidListViewModels = new PagedResult<SalaryAidViewModel>()
|
||||
{
|
||||
TotalCount = query.Count(),
|
||||
List = query.OrderByDescending(x => x.SalaryAidDateTime).ApplyPagination(searchModel.PageIndex,searchModel.PageSize).ToList()
|
||||
.Select(x => new SalaryAidViewModel()
|
||||
{
|
||||
Amount = x.Amount.ToMoney(),
|
||||
CreationDate = x.CreationDate.ToFarsi(),
|
||||
@@ -209,10 +212,12 @@ public class SalaryAidRepository : RepositoryBase<long, SalaryAid>, ISalaryAidRe
|
||||
WorkshopId = x.WorkshopId,
|
||||
YearFa = x.SalaryAidDateTime.ToFarsi().Substring(0, 4),
|
||||
MonthFa = x.SalaryAidDateTime.ToFarsi().Substring(5, 2),
|
||||
PersonnelCode = personnelCodes.FirstOrDefault(p => p.EmployeeId == x.EmployeeId).PersonnelCode.ToString(),
|
||||
PersonnelCode = personnelCodes.FirstOrDefault(p => p.EmployeeId == x.EmployeeId).PersonnelCode
|
||||
.ToString(),
|
||||
EmployeeFullName = employees.FirstOrDefault(e => e.id == x.EmployeeId).FullName,
|
||||
AmountDouble = x.Amount,
|
||||
}).ToList();
|
||||
}).ToList()
|
||||
};
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using _0_Framework.Application;
|
||||
using CompanyManagement.Infrastructure.Excel.SalaryAid;
|
||||
using CompanyManagment.App.Contracts.SalaryAid;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ServiceHost.BaseControllers;
|
||||
@@ -9,10 +10,12 @@ public class SalaryAidController:ClientBaseController
|
||||
{
|
||||
private readonly ISalaryAidApplication _salaryAidApplication;
|
||||
private readonly long _workshopId;
|
||||
private readonly SalaryAidImportExcel _salaryAidImportExcel;
|
||||
|
||||
public SalaryAidController(ISalaryAidApplication salaryAidApplication,IAuthHelper authHelper)
|
||||
public SalaryAidController(ISalaryAidApplication salaryAidApplication,IAuthHelper authHelper, SalaryAidImportExcel salaryAidImportExcel)
|
||||
{
|
||||
_salaryAidApplication = salaryAidApplication;
|
||||
_salaryAidImportExcel = salaryAidImportExcel;
|
||||
_workshopId = authHelper.GetWorkshopId();
|
||||
}
|
||||
|
||||
@@ -62,6 +65,13 @@ public class SalaryAidController:ClientBaseController
|
||||
var result = _salaryAidApplication.Remove(id);
|
||||
return result;
|
||||
}
|
||||
|
||||
public ActionResult<ExcelValidation<SalaryAidImportData>> OnPostValidateExcel(IFormFile excel)
|
||||
{
|
||||
var validation = _salaryAidImportExcel.ReadAndValidateExcel(excel, _workshopId);
|
||||
|
||||
return validation;
|
||||
}
|
||||
}
|
||||
|
||||
public class EditSalaryAidRequest
|
||||
|
||||
Reference in New Issue
Block a user