public async Task<ActionResult> SetRole(int id, FormCollection form, UserViewModel viewmodel) { var result = await UserRepository.SetRoleAsync(id, (Model.Types.RoleType)viewmodel.RoleId); if (result == Model.SaveResult.SUCCESS) return RedirectToAction("List"); return View(viewmodel); }
public async Task<ActionResult> SetRole(int id) { if (id == 0) return new HttpStatusCodeResult(HttpStatusCode.BadRequest); var user = await UserRepository.SingleAsync(id); if (user == null) return HttpNotFound(); //Find all role var roles = RoleRepository.GetAllAsync(); UserViewModel bind = new UserViewModel() { Email = user.Email, Salt = user.Salt, RegistedDate = user.RegistedDate, IsLocked = user.IsLocked, Lastname = user.Lastname, Firstname = user.Firstname, Phone = user.Phone, DepartmentId = user.DepartmentId, SiteId = user.SiteId, RoleId = user.RoleId, LastLoginDate = user.LastLoginDate }; bind.Roles = await roles; return View(bind); }