Ejemplo n.º 1
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));
        }
Ejemplo n.º 2
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"));
            }
        }