Exemplo n.º 1
0
        public void GetOrder_Should_Return_Order()
        {
            var db    = new Classes.MongoDB();
            var order = db.GetOrder(testId);

            Assert.IsNotNull(order);
        }
Exemplo n.º 2
0
        public void UpdateOrder_Should_Return_True()
        {
            var db    = new Classes.MongoDB();
            var order = db.GetOrder(testId);

            order.Status = StatusType.InProgress;
            Assert.IsTrue(db.UpdateOrder(order));
        }
Exemplo n.º 3
0
 public ActionResult Details(string id)
 {
     if (Session["IsAdmin"] != null)
     {
         Classes.MongoDB db    = new Classes.MongoDB();
         var             order = db.GetOrder(id);
         var             toys  = db.GetAllToys();
         Models.Order    model = new Models.Order();
         model.Id              = order.Id;
         model.Kid             = order.Kid;
         model.Status          = order.Status;
         model.Date            = order.Date;
         model.Toys            = order.Toys;
         model.ToyList         = toys.ToList();
         model.EditToys        = true;
         model.MissingToysList = MissingToy(order, toys.ToList()).ToList();
         return(View(model));
     }
     else
     {
         return(RedirectToAction("../Users/Login"));
     }
 }
Exemplo n.º 4
0
        public ActionResult Save(string id, StatusType statusType)
        {
            if (Session["IsAdmin"] != null || statusType.Equals(StatusType.Done))
            {
                Classes.MongoDB db = new Classes.MongoDB();
                bool            result;
                var             order            = db.GetOrder(id);
                var             toys             = db.GetAllToys().ToList();
                bool            allToysIsPresent = ControlToy(order, toys);
                if (allToysIsPresent == true || statusType.Equals(StatusType.InProgress))
                {
                    switch (order.Status)
                    {
                    case StatusType.InProgress:
                        if (!statusType.Equals(StatusType.InProgress))
                        {
                            RemoveToy(db, order, toys);
                            result = db.UpdateOrder(new Classes.Order
                            {
                                Id     = id,
                                Status = statusType
                            });
                        }
                        break;

                    case StatusType.Ready:
                        if (statusType.Equals(StatusType.InProgress))
                        {
                            AddToy(db, order, toys);
                            result = db.UpdateOrder(new Classes.Order
                            {
                                Id     = id,
                                Status = statusType
                            });
                        }
                        else if (statusType.Equals(StatusType.Done))
                        {
                            if (!statusType.Equals(StatusType.InProgress))
                            {
                                RemoveToy(db, order, toys);
                                result = db.UpdateOrder(new Classes.Order
                                {
                                    Id     = id,
                                    Status = statusType
                                });
                            }
                        }
                        break;
                    }
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(RedirectToAction("../Toys/MissingToy"));
                }
            }
            else
            {
                return(RedirectToAction("../Users/Login"));
            }
        }