public ActionResult Edit(int id, EditUserModel model) { try { if (ModelState.IsValid) { User user = new User() { UserID = model.UserID, UserName = model.Username, Password = model.Password, Email = model.Email, Description = model.Description, FullName = model.Fullname, Occupation = model.Occupation, Address = model.Address, Industry = model.Industry, AnualIcome = model.AnualIncome, BirthYear = model.BirthYear, UserTypeID = model.UserTypeId, PhoneNumber1 = model.Phone1, PhoneNumber2 = model.Phone2, PhoneNumber3 = model.Phone3, //CreatedUserID = SessionManager.UserInfo.UserID, UpdatedUserID = SessionManager.UserInfo.UserID, GroupID = model.GroupID, }; if (model.PartnerId > .0) { user.PartnerId = model.PartnerId; } UserService service = new UserService(); service.Update(user); return RedirectToAction("Index"); } // TODO: Add update logic here } catch (Exception ex) { Logger.Log(ex); ModelState.AddModelError("Error500", ex.Message); } return View(model); }
public ActionResult Edit(int id) { UserService service = new UserService(); User user = service.GetById(id); EditUserModel model = new EditUserModel(); model.CopyPropertiesFrom(user); model.Phone1 = user.PhoneNumber1; model.Phone2 = user.PhoneNumber2; model.Phone3 = user.PhoneNumber3; model.Username = user.UserName; model.Password = string.Empty; model.Fullname = user.FullName; return View(model); }