public ActionResult NewOrder(NewOrderBm newOrderBm) { if (!this.ModelState.IsValid) { return(RedirectToAction("NewOrder")); } this._service.AddNewOrder(newOrderBm); return(this.RedirectToAction("Orders")); }
public IHttpActionResult CreateOrder([FromBody] NewOrderBm newOrderBm) { if (!this.ModelState.IsValid) { return(this.StatusCode(HttpStatusCode.BadRequest)); } this._service.AddNewOrder(newOrderBm); return(StatusCode(HttpStatusCode.Created)); }
public void AddNewOrder(NewOrderBm newOrderBm) { SugarSachet sachet = this.Context.SugarSachets.Find(newOrderBm.Id); Order order = new Order(); order.OrderDate = DateTime.Today; order.PaperKg = newOrderBm.PaperKg; order.OrderStatus = OrderStatus.Ordered; order.SachetUniqueNumber = sachet.UniqueNumber; order.ClientPrefix = sachet.ClientPrefix.PrefixName; this.Context.Orders.Add(order); this.Context.SaveChanges(); }