Пример #1
0
        public UserPreferencesViewModel GetUserPreferences(int userId)
        {
            var user = _userRepository.GetById(userId);
            var userPreferences = new UserPreferencesViewModel(user);

            return userPreferences;
        }
Пример #2
0
        public bool UpdateUserPreferences(UserPreferencesViewModel model)
        {
            var preferencesChanged = false;

            var user = _userRepository.GetById(model.UserId);

            if (user.UserPreferences.LastUploadDays != model.NewestTime)
            {
                user.UserPreferences.LastUploadDays = model.NewestTime;
                preferencesChanged = true;
            }
            //if (user.UserPreferences.MaxFileSize != model.FileSize)
            //{
            //    user.UserPreferences.MaxFileSize = model.FileSize;
            //    preferencesChanged = true;
            //}

            if (user.UserPreferences.SearchMethod != model.SearchMethod)
            {
                user.UserPreferences.SearchMethod = model.SearchMethod;
                preferencesChanged = true;
            }

            _unitOfWork.Commit();

            return preferencesChanged;
        }
        public ActionResult SaveUserPreferences(UserPreferencesViewModel model)
        {
            var serverResponse = new ResponseMessageViewModel();
            model.UserId = (int)Session["CurrentUserId"];

            if (_userService.UpdateUserPreferences(model))
            {
                serverResponse.AddSuccess(ResourceKeyResolver.SuccessUserPreferencesUpdated);
                }
            else
            {
                serverResponse.AddError(ResourceKeyResolver.ErrorUserPreferencesUpdated);
            }

            TempData["ServerResponse"] = serverResponse;

            return RedirectToAction("ChangedPreferencesRedirect");
        }