Esempio n. 1
0
        public ActionResult Create(EditableUser model)
        {
            if (ModelState.IsValid)
            {
                User newUser = new User();
                newUser.Login = model.Login;
                newUser.LastName = model.LastName;
                newUser.FirstName = model.FirstName;
                newUser.Email = model.Email;
                newUser.CreationDate = DateTime.Now;
                newUser.Password = model.Password;

                var res = Manager.AddUser(newUser);
                if (!res.IsError)
                    Manager.UpdateRoles(newUser, model.UserRoles);

                return RedirectToAction("Index");
            }
            else
            {
                return View();
            }
        }
Esempio n. 2
0
        public ActionResult Edit(int id, EditableUser model)
        {
            if (ModelState.IsValid)
            {
                var user = new User();

                user.UserId = model.UserId;
                user.Login = model.Login;
                user.FirstName = model.FirstName;
                user.LastName = model.LastName;
                user.Email = model.Email;

                var res = Manager.EditUser(user);
                if (!res.IsError)
                    Manager.UpdateRoles(user, model.UserRoles);
                return RedirectToAction("Index");
            }
            else
            {
                ViewBag.RoleList = Manager.RepoGeneric.GetAll<Role>().ToList();
                return View(model);
            }
        }