コード例 #1
0
        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);
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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));
            }
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        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));
        }