예제 #1
0
        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"));
            }
        }
예제 #2
0
        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 }));
            }
        }
예제 #3
0
 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"));
     }
 }
예제 #4
0
파일: Orders.cs 프로젝트: phinkgoood/csharp
        public void UpdateOrder_Should_Return_True()
        {
            var db    = new SantaClauseVillageDB();
            var order = db.GetOrderById(orderId);

            order.StatusType = StatusType.ReadyToSent;
            Assert.IsTrue(db.UpdateOrder(order));
        }
예제 #5
0
파일: Orders.cs 프로젝트: phinkgoood/csharp
        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));
        }
예제 #6
0
        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 }));
        }