Ejemplo n.º 1
0
        public void GetOrder_Should_Return_TestOrder()
        {
            var db    = new ProjectMongoDB();
            var order = db.GetOrder(testId);

            Assert.IsNotNull(order);
        }
Ejemplo n.º 2
0
        public void GetAllOrders_Should_Return_A_List()
        {
            var db   = new ProjectMongoDB();
            var list = db.GetAllOrder();

            Assert.AreEqual(1, list.Count());
        }
Ejemplo n.º 3
0
        public ActionResult Save(OrderStatus status, string id)
        {
            ProjectMongoDB db = new ProjectMongoDB();
            bool           result;

            result = db.UpdateOrder(id, status);
            return(RedirectToAction("Index"));//, new { result = result }
        }
Ejemplo n.º 4
0
        public void UpdateOrder_Should_Return_True()
        {
            var db    = new ProjectMongoDB();
            var order = db.GetOrder(testId);

            order.Status = OrderStatus.InProgress;
            Assert.IsTrue(db.UpdateOrder(order.ID, order.Status));
        }
Ejemplo n.º 5
0
        public void GetToy_Should_Return_TestToy()
        {
            var db = new ProjectMongoDB();

            var toy = db.GetToy(toyID);

            Assert.IsNotNull(toy);
        }
Ejemplo n.º 6
0
        public ActionResult Index()
        {
            ProjectMongoDB db    = new ProjectMongoDB();
            var            toys  = db.GetAllToy();
            Toys           model = new Toys();

            model.EntityList = toys.ToList();
            return(View(model));
        }
Ejemplo n.º 7
0
        public ActionResult Edit(string id)
        {
            ProjectMongoDB db    = new ProjectMongoDB();
            var            order = db.GetOrder(id);
            Order          model = new Order();

            model.Status = order.Status;
            model.ID     = order.ID;
            return(View(model));
        }
Ejemplo n.º 8
0
        public ActionResult Details(string id)
        {
            ProjectMongoDB db    = new ProjectMongoDB();
            var            order = db.GetOrder(id);
            Order          model = new Order();

            model.ID          = order.ID;
            model.Kid         = order.Kid;
            model.Status      = order.Status;
            model.Toys        = order.Toys;
            model.RequestDate = order.RequestDate;
            return(View(model));
        }
Ejemplo n.º 9
0
        public void GetUser_Should_Return_TestUser()
        {
            var db   = new ProjectMongoDB();
            var test = new User
            {
                ScreenName        = EmailTest,
                Password          = User.Hash(PasswordTest),
                PasswordClearText = PasswordTest
            };
            var user = db.GetUser(test);

            Assert.IsNotNull(user);
        }
Ejemplo n.º 10
0
        public ActionResult Index()
        {
            ProjectMongoDB db     = new ProjectMongoDB();
            var            orders = db.GetAllOrder().ToList();

            if (Session["IsAdmin"] != null)
            {
                orders.ForEach(order => order.Toys = db.GetAllOrderPrice(order) as List <Toy>);
            }
            Orders model = new Orders();

            model.EntityList = orders;
            return(View(model));
        }
Ejemplo n.º 11
0
        public ActionResult Login(User user)
        {
            ProjectMongoDB db  = new ProjectMongoDB();
            var            usr = db.GetUser(user);

            if (usr != null)
            {
                Session["Email"]      = usr.Email.ToString();
                Session["ID"]         = usr.ID.ToString();
                Session["ScreenName"] = usr.ScreenName.ToString();
                if (usr.IsAdmin)
                {
                    Session["IsAdmin"] = usr.IsAdmin.ToString();
                }
                return(RedirectToAction($"../Home"));
            }
            else
            {
                ModelState.AddModelError("", "Username or Password Error");
            }
            return(View());
        }