Beispiel #1
0
        public async Task <IActionResult> AddOffer([FromForm] AddOfferRequest request)
        {
            var response = await mediator.Send(request);

            Log.Information($"User #{HttpContext.GetCurrentUserId()} created new offer #{response.Offer?.Id}");

            return(this.CreateResponse(response));
        }
Beispiel #2
0
        public async Task <IActionResult> AddOffer([FromRoute] string basketId, [FromBody] AddOfferRequest request)
        {
            var basket = await this.basketService.GetBasket(basketId);

            if (basket == null)
            {
                return(NotFound());
            }

            var validation = await this.basketValidationService.CheckOffer(basket, request.OfferCode);

            if (!validation.Success)
            {
                return(BadRequest(validation.Message));
            }

            // Add offer to basket
            await this.basketService.AddOffer(basketId, request.OfferCode);

            return(Ok());
        }