Esempio n. 1
0
        public async Task <ActionResult> Add(Users usr, HttpPostedFileBase postedFile)
        {
            if (ModelState.IsValid == false)
            {
                return(View(usr));
            }
            else
            {
                var response = await usrVM.Add(usr, postedFile);

                if (response == false)
                {
                    return(View(usr));
                }
            }
            return(RedirectToAction("User_Details"));
        }
        public void TestUserViewModel_AddUser()
        {
            UsersViewModel model = new UsersViewModel(new UsersWindow());

            model.Add();
            model.IsNew                 = true;
            model.SelectedUser.Name     = "Unit Test";
            model.SelectedUser.Email    = "*****@*****.**";
            model.SelectedUser.Password = "******";
            model.Save();

            WarehouseDbContext ctx = new WarehouseDbContext();
            var user = ctx.Users.SingleOrDefault(u => u.Name == "Unit Test");

            Assert.AreNotEqual(null, user, "User added !");

            //remove unit test user
            ctx.Users.Remove(user);
            ctx.SaveChanges();
        }