Example #1
0
        public async Task <IActionResult> CancelPromotionAsync([FromRoute] string promotionalCode)
        {
            var promotion = await _promotionService.FindPromotionOrNullAsync(promotionalCode);

            if (promotion == null)
            {
                return(this.NotFound("Promotion not found."));
            }

            var result = await _promotionService.CancelPromotionAsync(promotion, new UtcNowDateTimeProvider());

            if (result.IsValid)
            {
                return(this.Ok(_mapper.Map <PromotionDto>(result.Response)));
            }

            result.AddToModelState(ModelState);

            return(this.BadRequest(new ValidationProblemDetails(ModelState)));
        }