Exemple #1
0
        public ActionResult Save(string id, RequestStatus requestStatus)
        {
            xmasDB db    = new xmasDB();
            var    order = db.UpdateRequest(id, requestStatus);

            return(RedirectToAction("Detail", new { orderId = id }));
        }
Exemple #2
0
        public void Get_Order_Should_Return_Test_Order()
        {
            var db    = new xmasDB();
            var order = db.GetRequest(orderId.ToString());

            Assert.IsNotNull(order);
        }
Exemple #3
0
        public void Get_All_Orders_Should_Return_A_List_That_Contains_2_items()
        {
            var db   = new xmasDB();
            var list = db.GetAllRequests();

            Assert.AreEqual(2, list.Count());
        }
Exemple #4
0
        public void Get_All_Toys_Should_Return_A_List()
        {
            var db   = new xmasDB();
            var list = db.GetAllToys();

            Assert.AreEqual(2, list.Count());
        }
Exemple #5
0
        public ActionResult Index()
        {
            xmasDB db    = new xmasDB();
            var    toys  = db.GetAllToys().ToList();
            Toys   model = new Toys
            {
                EntityList = toys
            };

            return(View(model));
        }
Exemple #6
0
        public void Get_User_Should_Return_Test_User()
        {
            var db   = new xmasDB();
            var test = new User
            {
                Username = USERNAME,
                Password = USERPASSWORD
            };
            var user = db.GetUser(test);

            Assert.IsNotNull(user);
        }
Exemple #7
0
        public ActionResult Index()
        {
            xmasDB db     = new xmasDB();
            var    orders = db.GetAllRequests().ToList();

            orders.ForEach(order => order.Toys = db.GetAllOrderedToys(order) as List <Toy>);
            Orders model = new Orders
            {
                EntityList = orders
            };

            return(View(model));
        }
Exemple #8
0
 public ActionResult Update(string orderId)
 {
     if (orderId != null)
     {
         xmasDB  db    = new xmasDB();
         var     order = db.GetRequest(orderId);
         Request model = new Request
         {
             Id          = order.Id,
             Kid         = order.Kid,
             Status      = order.Status,
             Toys        = db.GetAllOrderedToys(order) as List <Toy>,
             RequestDate = order.RequestDate
         };
         return(View(model));
     }
     else
     {
         return(View());
     }
 }
Exemple #9
0
 public ActionResult Detail(string orderId)
 {
     if (orderId != null)
     {
         xmasDB  db    = new xmasDB();
         var     order = db.GetRequest(orderId);
         Request model = new Request
         {
             Id          = order.Id,
             Kid         = order.Kid,
             Status      = order.Status,
             Toys        = order.Toys,
             RequestDate = order.RequestDate
         };
         return(View(model));
     }
     else
     {
         return(View());
     }
 }
        public ActionResult Login(User user)
        {
            xmasDB db  = new xmasDB();
            var    usr = db.GetUser(user);

            if (usr != null)
            {
                Session["Email"]    = usr.Email.ToString();
                Session["UserID"]   = usr.Id.ToString();
                Session["Username"] = usr.Username.ToString();
                if (usr.IsAdmin)
                {
                    Session["IsAdmin"] = usr.IsAdmin.ToString();
                }
                return(RedirectToAction($"../Home"));
            }
            else
            {
                ModelState.AddModelError("", "Email or password incorrect");
            }
            return(View());
        }
Exemple #11
0
        public void Update_Order_Should_Return_True()
        {
            var db = new xmasDB();

            Assert.IsTrue(db.UpdateRequest(orderId.ToString(), RequestStatus.Done));
        }