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.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
|
public class SalaryAidSearchViewModel:PaginationRequest
|
||||||
{
|
{
|
||||||
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; }
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
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;
|
||||||
|
|
||||||
@@ -7,7 +8,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 List<SalaryAidViewModel> SalaryAidListViewModels { get; set; }
|
public PagedResult<SalaryAidViewModel> SalaryAidListViewModels { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -197,22 +197,27 @@ 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.SalaryAidListViewModels = query.OrderByDescending(x => x.SalaryAidDateTime).Skip(searchModel.PageIndex).Take(30).ToList().Select(
|
result.SalaryAidListViewModels = new PagedResult<SalaryAidViewModel>()
|
||||||
x => new SalaryAidViewModel()
|
{
|
||||||
{
|
TotalCount = query.Count(),
|
||||||
Amount = x.Amount.ToMoney(),
|
List = query.OrderByDescending(x => x.SalaryAidDateTime).ApplyPagination(searchModel.PageIndex,searchModel.PageSize).ToList()
|
||||||
CreationDate = x.CreationDate.ToFarsi(),
|
.Select(x => new SalaryAidViewModel()
|
||||||
Id = x.id,
|
{
|
||||||
EmployeeId = x.EmployeeId,
|
Amount = x.Amount.ToMoney(),
|
||||||
SalaryAidDateTimeFa = x.SalaryAidDateTime.ToFarsi(),
|
CreationDate = x.CreationDate.ToFarsi(),
|
||||||
SalaryAidDateTimeGe = x.SalaryAidDateTime,
|
Id = x.id,
|
||||||
WorkshopId = x.WorkshopId,
|
EmployeeId = x.EmployeeId,
|
||||||
YearFa = x.SalaryAidDateTime.ToFarsi().Substring(0, 4),
|
SalaryAidDateTimeFa = x.SalaryAidDateTime.ToFarsi(),
|
||||||
MonthFa = x.SalaryAidDateTime.ToFarsi().Substring(5, 2),
|
SalaryAidDateTimeGe = x.SalaryAidDateTime,
|
||||||
PersonnelCode = personnelCodes.FirstOrDefault(p => p.EmployeeId == x.EmployeeId).PersonnelCode.ToString(),
|
WorkshopId = x.WorkshopId,
|
||||||
EmployeeFullName = employees.FirstOrDefault(e => e.id == x.EmployeeId).FullName,
|
YearFa = x.SalaryAidDateTime.ToFarsi().Substring(0, 4),
|
||||||
AmountDouble = x.Amount,
|
MonthFa = x.SalaryAidDateTime.ToFarsi().Substring(5, 2),
|
||||||
}).ToList();
|
PersonnelCode = personnelCodes.FirstOrDefault(p => p.EmployeeId == x.EmployeeId).PersonnelCode
|
||||||
|
.ToString(),
|
||||||
|
EmployeeFullName = employees.FirstOrDefault(e => e.id == x.EmployeeId).FullName,
|
||||||
|
AmountDouble = x.Amount,
|
||||||
|
}).ToList()
|
||||||
|
};
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using _0_Framework.Application;
|
using _0_Framework.Application;
|
||||||
|
using CompanyManagement.Infrastructure.Excel.SalaryAid;
|
||||||
using CompanyManagment.App.Contracts.SalaryAid;
|
using CompanyManagment.App.Contracts.SalaryAid;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using ServiceHost.BaseControllers;
|
using ServiceHost.BaseControllers;
|
||||||
@@ -9,10 +10,12 @@ public class SalaryAidController:ClientBaseController
|
|||||||
{
|
{
|
||||||
private readonly ISalaryAidApplication _salaryAidApplication;
|
private readonly ISalaryAidApplication _salaryAidApplication;
|
||||||
private readonly long _workshopId;
|
private readonly long _workshopId;
|
||||||
|
private readonly SalaryAidImportExcel _salaryAidImportExcel;
|
||||||
|
|
||||||
public SalaryAidController(ISalaryAidApplication salaryAidApplication,IAuthHelper authHelper)
|
public SalaryAidController(ISalaryAidApplication salaryAidApplication,IAuthHelper authHelper, SalaryAidImportExcel salaryAidImportExcel)
|
||||||
{
|
{
|
||||||
_salaryAidApplication = salaryAidApplication;
|
_salaryAidApplication = salaryAidApplication;
|
||||||
|
_salaryAidImportExcel = salaryAidImportExcel;
|
||||||
_workshopId = authHelper.GetWorkshopId();
|
_workshopId = authHelper.GetWorkshopId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,6 +65,13 @@ public class SalaryAidController:ClientBaseController
|
|||||||
var result = _salaryAidApplication.Remove(id);
|
var result = _salaryAidApplication.Remove(id);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ActionResult<ExcelValidation<SalaryAidImportData>> OnPostValidateExcel(IFormFile excel)
|
||||||
|
{
|
||||||
|
var validation = _salaryAidImportExcel.ReadAndValidateExcel(excel, _workshopId);
|
||||||
|
|
||||||
|
return validation;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class EditSalaryAidRequest
|
public class EditSalaryAidRequest
|
||||||
|
|||||||
Reference in New Issue
Block a user