コード例 #1
0
        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);
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        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);
        }