PriceAnnouncementLogic.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using CZFW.Framework.Logic;
  2. using CZFW.Framework.Model.Entity;
  3. using CZKJ.GBRS2.Entity;
  4. using CZKJ.GBRS2.Interface;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. namespace CZKJ.GBRS2.Logic
  10. {
  11. public class PriceAnnouncementLogic : LogicBase<PriceAnnouncementEntity>, IPriceAnnouncement
  12. {
  13. public IList<PriceAnnouncementEntity> GetTableList(int? typeId, int pageIndex, int pageSize, out int rowsCount)
  14. {
  15. IQueryable<PriceAnnouncementEntity> query = DbContext.Set<PriceAnnouncementEntity>();
  16. if (typeId.HasValue)
  17. {
  18. query = query.Where(x => x.Typeofinsuance == typeId);
  19. }
  20. rowsCount = query.Count();
  21. var result = query.Join(DbContext.Set<TypeEntity>(), x => x.Typeofinsuance, y => y.Id, (x, y) => new { x, y.Name }).OrderByDescending(x => x.x.DateTime).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
  22. return result.Select(x => new PriceAnnouncementEntity
  23. {
  24. TypeName = x.Name,
  25. Id = x.x.Id,
  26. Typeofinsuance = x.x.Typeofinsuance,
  27. DateTime = x.x.DateTime,
  28. DayInterestRate = x.x.DayInterestRate,
  29. YearInterestRate = x.x.YearInterestRate,
  30. }).ToList();
  31. }
  32. }
  33. }