// GET: /User/Edit public ActionResult EditUser(string userName, AccountController.ManageMessageId? message = null) { using (var db = new ApplicationDbContext()) { ApplicationUser user = db.Users.First(u => u.UserName == userName); var model = new EditUserViewModel(); model.UserId = user.Id; model.UserName = user.UserName; model.FirstName = user.FirstName; model.MiddleName = user.MiddleName; model.LastName = user.LastName; model.Email = user.Email; model.IsActive = user.IsActive; ViewBag.MessageId = message; return View(model); } }
// GET: /Customer/Edit public ActionResult EditCustomer(string id, AccountController.ManageMessageId? message = null) { using (var db = new ApplicationDbContext()) { Customer customer = unitOfWork.Customers.FindById(id); var model = new EditCustomerViewModel(); model.CustomerId = customer.CustomerId; model.UserName = customer.User.UserName; model.FirstName = customer.User.FirstName; model.MiddleName = customer.User.MiddleName; model.LastName = customer.User.LastName; model.Email = customer.User.Email; model.RoleName = unitOfWork.Customers.GetRole(customer.CustomerId); var cusRoles = new ApplicationDbContext().Roles.Where(role => role.Name != "Admin").ToList(); foreach (var role in cusRoles) { model.Roles.Add(new SelectListItem { Text = role.Name, Value = role.Name }); } ViewBag.MessageId = message; return View(model); } }