Esempio n. 1
0
        public async Task UpdateQuantityAsync(string detailsId, short quantity)
        {
            var detailsDto = await _orderDetailsService.GetByIdAsync(detailsId);

            detailsDto.Quantity = quantity;
            await _orderDetailsService.UpdateAsync(detailsDto);
        }
Esempio n. 2
0
        public void UpdateQuantityAsync_SetsNewQuantityToExistingDetails_Always()
        {
            const int quantity = 1;

            A.CallTo(() => _orderDetailsService.GetByIdAsync(A <string> ._)).Returns(new OrderDetailsDto());

            _basketService.UpdateQuantityAsync(DetailsId, quantity);

            A.CallTo(() => _orderDetailsService.UpdateAsync(
                         A <OrderDetailsDto> .That.Matches(dto => dto.Quantity == quantity))).MustHaveHappenedOnceExactly();
        }
Esempio n. 3
0
        public async Task <IActionResult> UpdateAsync(ModifyOrderDetailsViewModel modifyOrderDetailsViewModel)
        {
            if (!ModelState.IsValid)
            {
                var viewModel = await _modifyOrderDetailsViewModelFactory.CreateAsync(modifyOrderDetailsViewModel);

                return(View("Update", viewModel));
            }

            var dto = _mapper.Map <OrderDetailsDto>(modifyOrderDetailsViewModel);
            await _orderDetailsService.UpdateAsync(dto);

            return(RedirectToAction("ListAsync", "Order"));
        }
        public async Task UpdateAsync_ThrowsException_WhenNullDto()
        {
            Func <Task> action = async() => await _orderDetailsService.UpdateAsync(null);

            await action.Should().ThrowAsync <InvalidServiceOperationException>();
        }
Esempio n. 5
0
 public async Task Put(OrderDetailsDto orderDetails)
 {
     await _orderDetailsService.UpdateAsync(orderDetails);
 }