CheckBoxsRepository.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using Aspose.Words.Lists;
  2. using AutoMapper;
  3. using NPOI.SS.Formula.Functions;
  4. using OASystem.Domain.Entities.Customer;
  5. using OASystem.Domain.Entities.Groups;
  6. using OASystem.Domain.ViewModels.CRM;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. namespace OASystem.Infrastructure.Repositories.Groups
  13. {
  14. public class CheckBoxsRepository : BaseRepository<Grp_CheckBoxs, Grp_CheckBoxsView>
  15. {
  16. private readonly IMapper _mapper;
  17. public CheckBoxsRepository(SqlSugarClient sqlSugar, IMapper mapper) :
  18. base(sqlSugar)
  19. {
  20. _mapper = mapper;
  21. }
  22. public List<Grp_CheckBoxs> GetCheckBoxsByDiid(int diid)
  23. {
  24. return Query(x=>x.Diid == diid).ToList();
  25. }
  26. public bool AddCheckBoxs(List<Grp_CheckBoxs> checkboxList)
  27. {
  28. return Adds(checkboxList) > 0;
  29. }
  30. public Task<bool> DelCheckBoxsByDiid(int diid)
  31. {
  32. return DeleteAsync(x => x.Diid == diid);
  33. }
  34. public async Task<bool> SaveCheckBoxs(List<Grp_CheckBoxs> checkboxList,int diid)
  35. {
  36. BeginTran();
  37. bool isTrue = await DelCheckBoxsByDiid(diid);
  38. if (checkboxList.Count > 0)
  39. {
  40. isTrue = AddCheckBoxs(checkboxList);
  41. }
  42. if (isTrue)
  43. {
  44. CommitTran();
  45. }
  46. else
  47. {
  48. RollbackTran();
  49. }
  50. return isTrue;
  51. }
  52. }
  53. }