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)); }
public IHttpActionResult SendReport(string token, int userId, int orderId, string email) { if (!ApplicationHelper.IsTokenValid(token, userId)) { return(Content(HttpStatusCode.BadRequest, "BadRequest")); } var order = OrdersLogic.GetOrder(orderId); if (order == null) { return(Content(HttpStatusCode.NotFound, "NotFound")); } var result = OrdersLogic.SendReport(order, email); if (!result.Success) { ApplicationHelper.Log(result.Message); } return(result.Success ? Content(HttpStatusCode.OK, "OK") : Content(HttpStatusCode.InternalServerError, result.Message)); }
public IHttpActionResult GetOrder(string token, int userId, int id) { if (!ApplicationHelper.IsTokenValid(token, userId)) { return(Content(HttpStatusCode.BadRequest, "BadRequest")); } var order = OrdersLogic.GetOrder(id); if (order == null) { return(Content(HttpStatusCode.NotFound, "NotFound")); } return(Content(HttpStatusCode.OK, order)); }