Esempio n. 1
0
        public IHttpActionResult UpdateOrder(string token, int userId, Order order)
        {
            if (!ModelState.IsValid || !ApplicationHelper.IsTokenValid(token, userId))
            {
                return(Content(HttpStatusCode.BadRequest, "BadRequest"));
            }

            var orderDb = OrdersLogic.GetOrder(order.orderId);

            if (orderDb == null)
            {
                return(Content(HttpStatusCode.NotFound, "NotFound"));
            }

            var result = OrdersLogic.UpdateOrder(order);

            if (!result.Success)
            {
                ApplicationHelper.Log(result.Message);
            }

            return(result.Success
                ? Content(HttpStatusCode.OK, "OK")
                : Content(HttpStatusCode.InternalServerError, result.Message));
        }