public async Task RemoveItemAsync(int branchId, int itemId) { var entity = await ItemStoreBranchRepository.GetAsync(e => e.StoreBranchID == branchId && e.ItemID == itemId) ?? throw new EntityNotFoundException(); await ItemStoreBranchRepository.DeleteAsync(entity); }
public async Task <ItemStoreBranchDto[]> GetAllItemsAsync( int branchId, int skipCount = 0, int maxResultCount = 10, bool includeDetails = false) { var entities = await ItemStoreBranchRepository .GetListAsync(e => e.StoreBranchID == branchId, skipCount, maxResultCount, includeDetails); return(ObjectMapper.Map <ItemStoreBranchEntity[], ItemStoreBranchDto[]>(entities)); }
public async Task AddToStoreBranch(int itemId, params int[] storeBranchIds) { _ = await Repository.FindAsync(itemId) ?? throw new EntityNotFoundException(); foreach (var id in storeBranchIds) { var storeBranchE = await StoreBranchRepository.GetAsync(id) ?? throw new EntityNotFoundException("One of the specified store branches does not exist"); await ItemStoreBranchRepository.InsertAsync(new ItemStoreBranchEntity(itemId, storeBranchE.Id)); } }
public async Task <ItemStoreBranchDto[]> SearchAsync( string keywords, int branchId, int skipCount = 0, int maxResultCount = 10, bool includeDetails = false) { var entities = await ItemStoreBranchRepository .SearchAsync(keywords, branchId, skipCount, maxResultCount, includeDetails); return(ObjectMapper.Map <ItemStoreBranchEntity[], ItemStoreBranchDto[]>(entities)); }
public async Task <ItemStoreBranchDto> AddItemAsync(int branchId, ItemStoreBranchDto dto) { if (dto == null) { throw new ArgumentNullException(); } _ = await Repository.GetAsync(branchId) ?? throw new BusinessException("Invalid branch id"); _ = await ItemRepository.GetAsync(dto.ItemID) ?? throw new BusinessException("Invalid item id"); var entity = await ItemStoreBranchRepository.InsertAsync(new ItemStoreBranchEntity(dto.ItemID, branchId)); return(ObjectMapper.Map <ItemStoreBranchEntity, ItemStoreBranchDto>(entity)); }