public static UserSettingsViewModel Populate(int userId, IUnitOfWork work = null) { if (work == null) { work = new UnitOfWork(); } UserSettingsViewModel model = new UserSettingsViewModel() { FacebookConnectionModel = FacebookConnectionViewModel.Populate(userId, work), PrivacySettings = work.UserRepository.GetPrivacySettingsById(userId), CommunicationSettings = work.UserRepository.GetCommunicationSettingsById(userId), }; return(model); }
public static UserSettingsViewModel Populate(int userId, IUnitOfWork work = null) { if (work == null) work = new UnitOfWork(); UserSettingsViewModel model = new UserSettingsViewModel() { FacebookConnectionModel = FacebookConnectionViewModel.Populate(userId, work), PrivacySettings = work.UserRepository.GetPrivacySettingsById(userId), CommunicationSettings = work.UserRepository.GetCommunicationSettingsById(userId), }; return model; }
public ActionResult Index(UserSettingsViewModel model) { if (ModelState.IsValid) { using (UnitOfWork work = new UnitOfWork()) { work.UserRepository.UpdateUserSettings(WebSecurity.CurrentUserId, model.CommunicationSettings, model.PrivacySettings); work.SaveChanges(); } // TODO: Figure out why model isn't being refreshed properly return RedirectToAction("Index"); } // TODO: refresh model? return View(model); }