cahnge salaryAidOrderBy

This commit is contained in:
MahanCh
2025-05-25 17:40:36 +03:30
parent 22d7c49379
commit 53e93bd410
3 changed files with 31 additions and 18 deletions

View File

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

View File

@@ -15,7 +15,8 @@ public class SalaryAidViewModel
public string CalculationDateTimeFa { get; set; }
public DateTime CalculationDateTimeGe { get; set; }
public int Month { get; set; }
public int Year { get; set; }
public string EmployeeFullName { get; set; }
public string PersonnelCode { get; set; }

View File

@@ -117,21 +117,29 @@ public class SalaryAidRepository : RepositoryBase<long, SalaryAid>, ISalaryAidRe
}
query = query.Where(x => x.EmployeeId == searchModel.EmployeeId);
var list = query.ToList().Select(x => new SalaryAidViewModel
var list = query.ToList().Select(x =>
{
Amount = x.Amount.ToMoney(),
AmountDouble = x.Amount,
EmployeeFullName = employees.FirstOrDefault(e => e.id == x.EmployeeId).FullName,
EmployeeId = x.EmployeeId,
CreationDate = x.CreationDate.ToFarsi(),
Id = x.id,
MonthFa = pc.GetMonth(x.CalculationDate).ToFarsiMonthByIntNumber(),
YearFa = pc.GetYear(x.CalculationDate).ToString(),
PersonnelCode = personnelCodes.FirstOrDefault(p => p.EmployeeId == x.EmployeeId).PersonnelCode.ToString(),
SalaryAidDateTimeFa = x.SalaryAidDateTime.ToFarsi(),
SalaryAidDateTimeGe = x.SalaryAidDateTime,
WorkshopId = x.WorkshopId
var monthInt = pc.GetMonth(x.CalculationDate);
var yearInt = pc.GetYear(x.CalculationDate);
return new SalaryAidViewModel
{
Amount = x.Amount.ToMoney(),
AmountDouble = x.Amount,
EmployeeFullName = employees.FirstOrDefault(e => e.id == x.EmployeeId).FullName,
EmployeeId = x.EmployeeId,
CreationDate = x.CreationDate.ToFarsi(),
Id = x.id,
MonthFa = monthInt.ToFarsiMonthByIntNumber(),
YearFa = yearInt.ToString(),
Month = monthInt,
Year = yearInt,
PersonnelCode = personnelCodes.FirstOrDefault(p => p.EmployeeId == x.EmployeeId).PersonnelCode
.ToString(),
SalaryAidDateTimeFa = x.SalaryAidDateTime.ToFarsi(),
SalaryAidDateTimeGe = x.SalaryAidDateTime,
WorkshopId = x.WorkshopId,
CalculationDateTimeGe = x.CalculationDate
};
}).ToList();
result.GroupedByDate = list.GroupBy(x => new { x.YearFa, x.MonthFa }).Select(x =>
new SalaryAidGroupedByDateViewModel()
@@ -144,10 +152,12 @@ public class SalaryAidRepository : RepositoryBase<long, SalaryAid>, ISalaryAidRe
EmployeeName = s.EmployeeFullName,
Id = s.Id,
PersonnelCode = s.PersonnelCode,
SalaryAidDateTimeFa = s.SalaryAidDateTimeFa
SalaryAidDateTimeFa = s.SalaryAidDateTimeFa,
}).ToList(),
Year = x.First().Year,
Month = x.First().Month,
TotalAmount = x.Sum(s => s.AmountDouble).ToMoney()
}).ToList();
}).OrderByDescending(x => x.Year).ThenByDescending(x=>x.Month).ToList();
return result;
}
else if (!string.IsNullOrWhiteSpace(searchModel.StartDate) &&
@@ -187,7 +197,7 @@ public class SalaryAidRepository : RepositoryBase<long, SalaryAid>, ISalaryAidRe
query = query.Where(x => x.SalaryAidDateTime >= startDate && x.SalaryAidDateTime <= endDate);
}
result.SalaryAidListViewModels = query.OrderByDescending(x => x.CreationDate).Skip(searchModel.PageIndex).Take(30).ToList().Select(
result.SalaryAidListViewModels = query.OrderByDescending(x => x.SalaryAidDateTime).Skip(searchModel.PageIndex).Take(30).ToList().Select(
x => new SalaryAidViewModel()
{
Amount = x.Amount.ToMoney(),