public ActionResult Edit(int id) { UserEditItem userItem = new UserEditItem(); if (id != 0) { var user = Manager.GetById(id); if (user != null) { userItem.Id = user.Id; userItem.UserName = user.UserName; userItem.Email = user.Email; userItem.EmailConfirmed = user.EmailConfirmed; userItem.PhoneNumber = user.PhoneNumber; userItem.PhoneNumberConfirmed = user.PhoneNumberConfirmed; userItem.LockoutEnabled = user.LockoutEnabled; userItem.LockoutEndDateUtc = user.LockoutEndDateUtc; userItem.City = user.City; userItem.AvatarName = user.AvatarName; userItem.ClientDataId = user.ClientDataId; userItem.ClientData = user.ClientDataId.HasValue ? new ClientDataItem { Id = user.ClientDataId.Value, FirstName = user.ClientData.FirstName, LastName = user.ClientData.LastName } : new ClientDataItem(); if (user.Roles.Count() > 0) { var role = RoleManager.GetRoleById(user.Roles.FirstOrDefault().RoleId); userItem.Type = role != null ? role.Name : userItem.Type = "Client"; } else { userItem.Type = "Client"; } } } else { userItem.LockoutEndDateUtc = DateTime.Today; } return View("AdminUserEditView", userItem); }