Beispiel #1
0
        public async Task <ActionResult <OrderViewModel> > PostAsync([FromBody] CreateOrderViewModel pe)
        {
            _logger.LogDebug("Post {0} {1} {2}", pe.OfferId, pe.StartDate, pe.CustomerId);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = await _repository.CreateOrderAsync(pe.OfferId, pe.StartDate, pe.CustomerId);

            if (!result)
            {
                return(BadRequest(new ProblemDetails()
                {
                    Detail = result.Message
                }));
            }

            return(CreatedAtRoute("Order" + nameof(GetAsync), new { id = result.Data.OrderId }, _mapper.Map <OrderViewModel>(result.Data)));
        }