public ActionResult UserModel(string user_name) { UserModel model = new UserModel(); if (!string.IsNullOrEmpty(user_name)) { var user = Membership.GetUser(user_name); model = Autorent.WebFace.Models.Administration.UserModel.FromDomainModel(user); } return View(model); }
public ActionResult UserModel(UserModel model, HttpPostedFileBase user_photo) { if (ModelState.IsValid) { if (user_photo != null) { FileUpload.DeleteFile(model.Photo); model.Photo = FileUpload.UploadFile(user_photo); } var user = Membership.GetUser(model.ID); model.AssignTo(user); return RedirectToAction("Index", "Administration"); } return View(model); }
public ActionResult Index(int page = 1, string sort = "Name", string sortDir = "Ascending") { int totalRecords; List<UserModel> users = new List<UserModel>(); MembershipUserCollection userList = Membership.GetAllUsers(page, pageSize, out totalRecords); foreach (MembershipUser item in userList) { var current_role = e_Role.User; var current_user = new UserModel { ID = Guid.Parse(item.ProviderUserKey.ToString()), Username = item.UserName, Email = item.Email, Role = (Enum.TryParse<e_Role>(Roles.GetRolesForUser(item.UserName).First(), out current_role)) ? current_role : current_role }; users.Add(current_user); } PagedUsersModel model = new PagedUsersModel { PageSize = pageSize, PageNumber = page, Users = users, TotalRows = totalRecords }; if (Request.IsAjaxRequest()) { return PartialView("AjaxUserModel_Grid", model); } return View(model); }