public ActionResult DetailsOrder(string id) { if (Session["ID"] != null) { SantaClauseVillageMongoDB db = new SantaClauseVillageMongoDB(); var order = db.GetOrderById(id); Order model = new Order(); model.ID = order.ID; model.Kid = order.Kid; model.StatusType = order.StatusType; List <Toy> ToysModel = new List <Toy>(); for (int i = 0; i < order.Toys.Count; i++) { ToysModel.Add(db.GetToyByName(order.Toys[i].Name)); } model.RequestDate = order.RequestDate; model.Toys = ToysModel; return(View(model)); } else { return(RedirectToAction("Index", "Home")); } }
public ActionResult SaveOrder(string id, StatusType statusType) { bool result; SantaClauseVillageMongoDB db = new SantaClauseVillageMongoDB(); Order order = db.GetOrderById(id); if (order != null) { result = db.UpdateOrder(new Order { ID = id, StatusType = statusType }); if (result == true) { return(RedirectToAction("OrdersList", new { result = result })); } else { return(RedirectToAction("DetailsOrder", new { error = true })); } } else { return(RedirectToAction("OrderList", new { error = true })); } }
public ActionResult DetailsOrder(string id, bool?error) { if (Session["ID"] != null) { if (error == true) { ModelState.AddModelError("", "Status Type not updated!"); } SantaClauseVillageMongoDB db = new SantaClauseVillageMongoDB(); var order = db.GetOrderById(id); if (order != null) { Order model = new Order(); model.ID = order.ID; model.Kid = order.Kid; model.StatusType = order.StatusType; List <Toy> ToysModel = new List <Toy>(); for (int i = 0; i < order.Toys.Count; i++) { ToysModel.Add(db.GetToyByName(order.Toys[i].Name)); } model.RequestDate = order.RequestDate; model.Toys = ToysModel; return(View(model)); } else { return(RedirectToAction("OrdersList", new { error = true })); } } else { return(RedirectToAction("Index", "Home")); } }
public void UpdateOrder_Should_Return_True() { var db = new SantaClauseVillageDB(); var order = db.GetOrderById(orderId); order.StatusType = StatusType.ReadyToSent; Assert.IsTrue(db.UpdateOrder(order)); }
public void GetOrderById_Should_Return_An_Object_Order() { var db = new SantaClauseVillageDB(); var order = db.GetOrderById(orderId); Assert.IsNotNull(order); Assert.IsInstanceOfType(order, typeof(Order)); }
public ActionResult SaveOrder(string id, StatusType statusType) { bool result; SantaClauseVillageMongoDB db = new SantaClauseVillageMongoDB(); Order order = db.GetOrderById(id); result = db.UpdateOrder(new Order { ID = id, StatusType = statusType }); return(RedirectToAction("OrdersList", new { result = result })); }