Beispiel #1
0
        public HttpResponseMessage PostOrder(int id, OrderItemDto orderItemDto)
        {
            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }

            var orderItem = _orderService.Add(orderItemDto.ToEntity());

            orderItemDto.Id = orderItem.Id;

            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, orderItemDto);

            return response;
        }
Beispiel #2
0
        public HttpResponseMessage PutOrder(int id, OrderItemDto orderItemDto)
        {
            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }

            if (id != orderItemDto.Id)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }

            _orderService.Update(orderItemDto.ToEntity());

            return Request.CreateResponse(HttpStatusCode.OK);
        }