GroupCostRepository.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using OASystem.Domain.Entities.Groups;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace OASystem.Infrastructure.Repositories.Groups
  8. {
  9. public class GroupCostRepository:BaseRepository<Grp_GroupCost, GroupCostView>
  10. {
  11. public GroupCostRepository(SqlSugarClient sqlSugar) : base(sqlSugar)
  12. {}
  13. public List<Grp_GroupCost> GetAllByDiid(int diid)
  14. {
  15. return Query(x => x.Diid == diid).ToList();
  16. }
  17. public List<Grp_GroupCost> GetAll()
  18. {
  19. return Query(x=> x.IsDel < 1).ToList();
  20. }
  21. public async Task<bool> SaveGroupCostList(List<Grp_GroupCost> costList,int diid)
  22. {
  23. BeginTran();
  24. bool isTrue = await DeleteGroupCostList(diid);
  25. if (costList.Count > 0)
  26. {
  27. isTrue = Adds(costList) > 0;
  28. }
  29. if (isTrue)
  30. {
  31. CommitTran();
  32. }
  33. else
  34. {
  35. RollbackTran();
  36. }
  37. return isTrue;
  38. }
  39. public Task<bool> DeleteGroupCostList(int diid)
  40. {
  41. return DeleteAsync(x => x.Diid == diid);
  42. }
  43. }
  44. }