52 lines
1.6 KiB
C#
52 lines
1.6 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using _0_Framework.Application;
|
|
using _0_Framework.InfraStructure;
|
|
using Company.Domain.DateSalaryItemAgg;
|
|
using CompanyManagment.App.Contracts.DateSalaryItem;
|
|
|
|
namespace CompanyManagment.EFCore.Repository;
|
|
|
|
public class DateSalaryItemRepository : RepositoryBase<long, DateSalaryItem>, IDateSalaryItemRepository
|
|
{
|
|
private readonly CompanyContext _context;
|
|
|
|
public DateSalaryItemRepository(CompanyContext context) : base(context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
|
|
public EditDateSalaryItem GetDetails(long id)
|
|
{
|
|
//return _context.DateSalaries.Select(x => new EditDateSalaryItem()
|
|
//{
|
|
// StartDateFa = x.StartDateFa,
|
|
// EndDateFa = x.EndDateFa,
|
|
//}).FirstOrDefault(x => x.Id == id);
|
|
return null;
|
|
}
|
|
|
|
public List<DateSalaryItemViewModel> Search(DateSalaryItemSearchModel searchModel)
|
|
{
|
|
var query = _context.DateSalaryItems.Select(x => new DateSalaryItemViewModel()
|
|
{
|
|
Id = x.id,
|
|
Percent = x.Percent,
|
|
PercentageId = x.PercentageId,
|
|
DateSalaryId = x.DateSalaryId,
|
|
Salary = x.Salary,
|
|
StrSalary = x.Salary.ToMoney(),
|
|
CreationDate = x.CreationDate,
|
|
});
|
|
var list = query.OrderByDescending(x => x.Id).ToList();
|
|
|
|
if (searchModel.DateSalaryId!=0)
|
|
list = list.Where(x => x.DateSalaryId == searchModel.DateSalaryId).OrderByDescending(x => x.CreationDate).ToList();
|
|
if (searchModel.Percent != 0)
|
|
list = list.Where(x => x.Percent == searchModel.Percent).ToList();
|
|
return list;
|
|
}
|
|
|
|
|
|
} |