Ejemplo n.º 1
0
        public async Task <IActionResult> Add([FromBody] NewBaskedItemRequest newBaskedItemRequest)
        {
            var newBasket = mapper.Map <Basket>(newBaskedItemRequest);
            var Basket    = await basketService.AddAsync(newBasket);

            return(Ok(Basket));
        }
Ejemplo n.º 2
0
        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)));
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
        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"));
        }
Ejemplo n.º 5
0
        public void CreateAsync_CallsService_Always()
        {
            _apiOrderController.CreateAsync(Id);

            A.CallTo(() => _basketService.AddAsync(A <string> ._, A <string> ._)).MustHaveHappenedOnceExactly();
        }