FBAOtherRepository.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using Dapper;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using XYY.Core.Standard.Data.Infrastructure;
  8. using XYY.Model.Standard.Order;
  9. using XYY.Model.Standard.Order.FBA;
  10. namespace XYY.Data.Standard.Order
  11. {
  12. public interface IFBAOtherRepository : IBaseRepository<FBA_OtherFee>
  13. {
  14. Task SaveOrAdd(FBA_OtherFee otherFee);
  15. Task<List<FBA_OtherFee>> GetAll();
  16. }
  17. public class FBAOtherRepository : BaseRepository<FBA_OtherFee>, IFBAOtherRepository
  18. {
  19. public FBAOtherRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
  20. {
  21. }
  22. public async Task<List<FBA_OtherFee>> GetAll()
  23. {
  24. return (await _unitOfWork.QueryAsync<FBA_OtherFee>()).ToList();
  25. }
  26. public async Task SaveOrAdd(FBA_OtherFee otherFee)
  27. {
  28. if (await _unitOfWork.IsExistsAsync<FBA_OtherFee>(x => x.Name == otherFee.Name && x.Id != otherFee.Id))
  29. throw new Exception($"系统内已存在名为{otherFee.Name}的附加费品类,请不要重复添加");
  30. if (otherFee.Id == 0)
  31. await _unitOfWork.InsertAsync(otherFee);
  32. else
  33. await _unitOfWork.UpdateAsync(otherFee);
  34. }
  35. }
  36. }