public async Task <IActionResult> Add([FromBody] NewBaskedItemRequest newBaskedItemRequest) { var newBasket = mapper.Map <Basket>(newBaskedItemRequest); var Basket = await basketService.AddAsync(newBasket); return(Ok(Basket)); }
public async Task <IActionResult> AddAsync(string key) { if (string.IsNullOrEmpty(key)) { return(BadRequest()); } var userId = User?.GetId(); await _basketService.AddAsync(key, userId); return(RedirectToAction(nameof(IndexAsync))); }
public async Task <IActionResult> CreateAsync(string gameId) { var game = await _gameService.GetByIdAsync(gameId, Culture.Current); var orderId = await _basketService.AddAsync(game.Key, User?.GetId()); var order = await _detailedOrderViewModelFactory.CreateAsync(orderId); _logger.LogDebug($"Create order with id {orderId}"); return(CreatedAtAction(nameof(GetByIdAsync), new { id = orderId }, order)); }
public async Task <IActionResult> Add(int id) { var getProductResult = await productsService.GetAsync(id); if (getProductResult.Status != Utilites.Status.OK) { ViewBag.ErrorMessage = getProductResult.Message; return(View()); } var result = await basketService.AddAsync(getProductResult.Value); if (result.Status != Utilites.Status.OK) { ViewBag.ErrorMessage = result.Message; return(View()); } return(RedirectToAction("Index", "Products")); }
public void CreateAsync_CallsService_Always() { _apiOrderController.CreateAsync(Id); A.CallTo(() => _basketService.AddAsync(A <string> ._, A <string> ._)).MustHaveHappenedOnceExactly(); }