public Order Update(Order order) { using (var client = new HttpClient()) { HttpResponseMessage response = client.PostAsJsonAsync("http://localhost:9885/api/Order/", order.Id).Result; return response.Content.ReadAsAsync<Order>().Result; } }
public ActionResult BuyConfirmed(ShoppingCart cart) { Customer customer = (Customer) TempData["customer"]; Order order = new Order { Customer = customer, CustomerId = customer.Id, Date = DateTime.Now, OrderLines = cart.orderLines }; _facade._orderRepository.Add(order); cart.CleanCart(); return View("Confirmed"); }
public ActionResult BuyConfirmed(ShoppingCart cart) { Customer customer = (Customer) TempData["customer"]; Order order = new Order { Customer = customer, CustomerId = customer.Id, Date = DateTime.Now, OrderLines = cart.orderLines }; service.CreateOne(order); //_efService.Orders.Create(order); //_efService.Save(); cart.CleanCart(); return View("Confirmed"); }
// POST: api/Orders public HttpResponseMessage PostOrder(Order order) { if (!ModelState.IsValid) { return Request.CreateResponse(HttpStatusCode.BadRequest, ModelState); } try { order = service.Orders.Create(order); service.Save(); var response = Request.CreateResponse(HttpStatusCode.Created, order); string uri = Url.Link("DefaultApi", new { id = order.Id }); response.Headers.Location = new Uri(uri); return response; } catch (Exception ex) { return Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message); } }
// PUT: api/Orders/5 public HttpResponseMessage PutOrder(int id, Order order) { if (!ModelState.IsValid) { return Request.CreateResponse(HttpStatusCode.BadRequest, ModelState); } if (id != order.Id) { return Request.CreateResponse(HttpStatusCode.BadRequest, "Orders id is not the same with given id"); } try { service.Orders.Update(order); service.Save(); } catch (Exception ex) { if (!OrderExists(id)) { return Request.CreateResponse(HttpStatusCode.NotFound, "Order with given id not found"); } return Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message); } return Request.CreateResponse(HttpStatusCode.OK, order); }
public OrderDto PutOrder(Order order) { var orders = dalFacade._orderRepository.Edit(order); return orderConverter.Convert(orders); }