Exemple #1
0
        public ActionResult CreateUser(User user)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    WebSecurity.CreateUserAndAccount(user.Username, user.Password, new
                    {
                        Email = user.Email,
                        Country = user.Country,
                        JoinDateTime = DateTime.Now,
                        Status = Status.Active,
                        DateOfBirth = user.DateOfBirth.ToString("dd-MM-yyyy"),
                        Gender = user.Gender,
                        Password = "******"
                    });
                    Roles.AddUserToRole(user.Username, "user");

                    return RedirectToAction("../Home/Album");
                }
                catch
                {
                }
            }
            ViewBag.CountryList = GetCountries();
            return View(user);
        }
Exemple #2
0
        public ActionResult EditUser(FormCollection form, User user)
        {
            AccountController ac = new AccountController();
            ViewBag.CountryList = ac.GetCountries();

            if (user.Status.ToString() != "Active")
            {
                user.DeleteDateTime = System.DateTime.Now;
            }
            else
            {
                user.DeleteDateTime = null;
            }

            if (ModelState.IsValid)
            {
                dbContext.Entry(user).State = EntityState.Modified;
                dbContext.SaveChanges();
                return RedirectToAction("UserManagement");
            }
            return View(user);
        }