GroupCostParameterRepository.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 async Task<bool> DeleteGroupCostParameterListByDiid(int diid)
  21. {
  22. return await SoftDeleteAsync(x=>x.DiId == diid);
  23. }
  24. public async Task<bool> SaveAsync(List<Grp_GroupCostParameter> List,int Userid, int diid)
  25. {
  26. bool isTrue = false;
  27. try
  28. {
  29. BeginTran();
  30. isTrue = await DeleteGroupCostParameterListByDiid(diid);
  31. if (List.Count > 0)
  32. {
  33. List.ForEach(x => { x.CreateUserId = Userid; x.CreateTime = DateTime.Now; });
  34. isTrue = Adds(List) > 0;
  35. }
  36. CommitTran();
  37. }
  38. catch (Exception ex)
  39. {
  40. RollbackTran();
  41. isTrue = false;
  42. }
  43. return isTrue;
  44. }
  45. }
  46. }