GroupCostParameterRepository.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using AutoMapper;
  2. using OASystem.Domain.Entities.Groups;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace OASystem.Infrastructure.Repositories.Groups
  9. {
  10. public class GroupCostParameterRepository : BaseRepository<Grp_GroupCostParameter, Grp_GroupCostParameterView>
  11. {
  12. public GroupCostParameterRepository(SqlSugarClient sqlSugar) :
  13. base(sqlSugar)
  14. {
  15. }
  16. public List<Grp_GroupCostParameter> GetGroupCostParameterListByDiid(int diid)
  17. {
  18. return Query(x=>x.DiId == diid).ToList();
  19. }
  20. public Grp_GroupCostParameter GetGroupCostParameterMainByDiid(int diid)
  21. {
  22. return Query(x => x.DiId == diid).First(x => x.CostType == "A");
  23. }
  24. public async Task<bool> UpdateIsShareById(int id,int IsShare)
  25. {
  26. return await UpdateAsync(x => x.Id == id, x=>new Grp_GroupCostParameter { IsShare = IsShare });
  27. }
  28. public async Task<bool> DeleteGroupCostParameterListByDiid(int diid)
  29. {
  30. return await SoftDeleteAsync(x=>x.DiId == diid);
  31. }
  32. public async Task<bool> SaveAsync(List<Grp_GroupCostParameter> List,int Userid, int diid)
  33. {
  34. bool isTrue = false;
  35. try
  36. {
  37. BeginTran();
  38. isTrue = await DeleteGroupCostParameterListByDiid(diid);
  39. if (List.Count > 0)
  40. {
  41. List.ForEach(x => { x.CreateUserId = Userid; x.CreateTime = DateTime.Now; });
  42. isTrue = Adds(List) > 0;
  43. }
  44. CommitTran();
  45. }
  46. catch (Exception ex)
  47. {
  48. RollbackTran();
  49. isTrue = false;
  50. }
  51. return isTrue;
  52. }
  53. }
  54. }