public ActionResult <decimal> TrolleyTotal(Trolley trolley) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } return(_trolleyService.GetTrolleyTotal(trolley)); }
public void GetTrolleyTotal_ShouldGetTrolleyTotalForTrolleyEntity() { var entity = new TrolleyEntity { Products = new List <TrolleyProductEntity> { new TrolleyProductEntity { Name = "Foo Product", Price = 1 } }, Quantities = new List <TrolleyProductQuantityEntity> { new TrolleyProductQuantityEntity { Name = "Foo Product Quantity", Quantity = 1 } }, Specials = new List <TrolleySpecialEntity> { new TrolleySpecialEntity { Quantities = new List <TrolleyProductQuantityEntity> { new TrolleyProductQuantityEntity { Name = "Foo Special Product Quantity", Quantity = 1 } }, Total = 1 } } }; var expectedTotal = "123"; _mockTrolleyRepository.Setup(s => s.GetTrolleyTotal(entity)).ReturnsAsync(expectedTotal); var result = _sut.GetTrolleyTotal(entity).Result; Assert.Equal(expectedTotal, result); }
public async Task <string> Handle(GetTrolleyTotalRequest request, CancellationToken cancellationToken) { var trolleyEntity = _mapper.Map <TrolleyEntity>(request.Trolley); return(await _trolleyService.GetTrolleyTotal(trolleyEntity).ConfigureAwait(false)); }