Пример #1
0
 public IActionResult RegisterFilter(UserViewModel userviewmodel)
 {
     if (ModelState.IsValid)
     {
         userviewmodel.HelperType = "add";
         if (userviewmodel.AddEditUser(userviewmodel) == false || userviewmodel.EmailValidator(userviewmodel) == false)
         {
             ViewBag.Message = "No Special Characters";
             return(View("~/Views/Home/Register.cshtml"));
         }
         userviewmodel.AddEditUser(userviewmodel);
         return(RedirectToAction("Login", "Home"));
     }
     ViewBag.Message = "All Boxes must be filled";
     return(View("~/Views/Home/Register.cshtml"));
 }
Пример #2
0
        public void Test_AddEditUser()
        {
            var sutAdd = new UserViewModel
            {
                HelperType = "add",
                Username   = "******",
                Password   = "******",
                Firstname  = "Bob",
                Lastname   = "Jan",
                Email      = "*****@*****.**"
            };
            var test = sutAdd.AddEditUser(sutAdd);

            Assert.True(test);
        }
Пример #3
0
        public IActionResult EditUserInfo(UserViewModel user)
        {
            var sessionUserId = HttpContext.Session.GetInt32("UserId");

            var editedUser = new UserViewModel
            {
                UserId    = (int)sessionUserId,
                Firstname = user.Firstname,
                Lastname  = user.Lastname,
                Email     = user.Email,
                Username  = user.Username,
                Password  = user.Password
            };

            if (editedUser.AddEditUser(editedUser))
            {
                HttpContext.Session.SetString("Username", user.Username);
            }
            return(RedirectToAction("Account", "Home"));
        }