GroupCostParameterRepository.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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> SaveAsync(List<Grp_GroupCostParameter> List,int UserId)
  21. {
  22. var AddList = List.Where(x => x.Id == 0).ToList();
  23. var UpdateList = List.Where(x => x.Id != 0).ToList();
  24. BeginTran();
  25. bool isTrue = false;
  26. if (AddList.Count > 0)
  27. {
  28. AddList.ForEach(x => { x.CreateUserId = UserId; x.CreateTime = DateTime.Now; });
  29. isTrue = Adds(AddList) > 0;
  30. }
  31. if (UpdateList.Count > 0)
  32. {
  33. isTrue = await _sqlSugar.Updateable<Grp_GroupCostParameter>(UpdateList).ExecuteCommandHasChangeAsync();
  34. }
  35. return isTrue;
  36. }
  37. }
  38. }