Example #1
0
        public async Task <ActionResult <OrderResponseDTO> > OrderInsert(OrderPostDTO orderPostDTO)
        {
            // Map orderPostDTO to repositories Order entity
            var newOrder = _mapper.Map <Order>(orderPostDTO);

            // Apply audit changes to Order entity
            newOrder = Audit <Order> .PerformAudit(newOrder);

            // Insert new Order into the respository
            newOrder = await _orderRespository.Insert(newOrder);

            // Map the Order entity to DTO response object and return in body of response
            var orderResponseDTO = _mapper.Map <OrderResponseDTO>(newOrder);

            return(CreatedAtAction(nameof(OrderGetById), new { orderResponseDTO.OrderId }, orderResponseDTO));
        }