public ActionResult Settings() { var model = new PictureSettingsModel(); var user = _userContext.CurrentUser; model.ActiveSettings = "PictureSettings"; var pictureSettings = _settingService.GetSettingsByType(SettingTypeEnum.PictureSetting).ToList(); if (pictureSettings.Count > 0) { foreach (var setting in pictureSettings) { if (setting.Name == "MaxWidthAllowedForLargeThumbnails") { model.MaxWidthAllowedForLargeThumbnails = setting.Value; } if (setting.Name == "MaxWidthAllowedForMediumThumbnails") { model.MaxWidthAllowedForMediumThumbnails = setting.Value; } if (setting.Name == "MaxWidthAllowedForSmallThumbnails") { model.MaxWidthAllowedForSmallThumbnails = setting.Value; } if (setting.Name == "MaxWidthAllowedForSliderThumbnails") { model.MaxWidthAllowedForSliderThumbnails = setting.Value; } if (setting.Name == "MaxHeightAllowedForLargeThumbnails") { model.MaxHeightAllowedForLargeThumbnails = setting.Value; } if (setting.Name == "MaxHeightAllowedForMediumThumbnails") { model.MaxHeightAllowedForMediumThumbnails = setting.Value; } if (setting.Name == "MaxHeightAllowedForSmallThumbnails") { model.MaxHeightAllowedForSmallThumbnails = setting.Value; } if (setting.Name == "MaxHeightAllowedForSliderThumbnails") { model.MaxHeightAllowedForSliderThumbnails = setting.Value; } } } return(View(model)); }
public ActionResult Settings(PictureSettingsModel model) { if (!_permissionService.Authorize("ManageSettings")) { return(AccessDeniedView()); } var user = _userContext.CurrentUser; try { if (ModelState.IsValid) { var maxWidthAllowedForLargeThumbnailsSetting = _settingService.GetSettingByKey("MaxWidthAllowedForLargeThumbnails"); if (maxWidthAllowedForLargeThumbnailsSetting != null) { maxWidthAllowedForLargeThumbnailsSetting.ModifiedOn = DateTime.Now; maxWidthAllowedForLargeThumbnailsSetting.Value = model.MaxWidthAllowedForLargeThumbnails; _settingService.Update(maxWidthAllowedForLargeThumbnailsSetting); } var maxWidthAllowedForMediumThumbnailsSetting = _settingService.GetSettingByKey("MaxWidthAllowedForMediumThumbnails"); if (maxWidthAllowedForMediumThumbnailsSetting != null) { maxWidthAllowedForMediumThumbnailsSetting.ModifiedOn = DateTime.Now; maxWidthAllowedForMediumThumbnailsSetting.Value = model.MaxWidthAllowedForMediumThumbnails; _settingService.Update(maxWidthAllowedForMediumThumbnailsSetting); } var maxWidthAllowedForSmallThumbnailsSetting = _settingService.GetSettingByKey("MaxWidthAllowedForSmallThumbnails"); if (maxWidthAllowedForSmallThumbnailsSetting != null) { maxWidthAllowedForSmallThumbnailsSetting.ModifiedOn = DateTime.Now; maxWidthAllowedForSmallThumbnailsSetting.Value = model.MaxWidthAllowedForSmallThumbnails; _settingService.Update(maxWidthAllowedForSmallThumbnailsSetting); } var maxWidthAllowedForSliderThumbnailsSetting = _settingService.GetSettingByKey("MaxWidthAllowedForSliderThumbnails"); if (maxWidthAllowedForSliderThumbnailsSetting != null) { maxWidthAllowedForSliderThumbnailsSetting.ModifiedOn = DateTime.Now; maxWidthAllowedForSliderThumbnailsSetting.Value = model.MaxWidthAllowedForSliderThumbnails; _settingService.Update(maxWidthAllowedForSliderThumbnailsSetting); } var maxHieghtAllowedForLargeThumbnailsSetting = _settingService.GetSettingByKey("MaxHeightAllowedForLargeThumbnails"); if (maxHieghtAllowedForLargeThumbnailsSetting != null) { maxHieghtAllowedForLargeThumbnailsSetting.ModifiedOn = DateTime.Now; maxHieghtAllowedForLargeThumbnailsSetting.Value = model.MaxHeightAllowedForLargeThumbnails; _settingService.Update(maxHieghtAllowedForLargeThumbnailsSetting); } var maxHieghtAllowedForMediumThumbnailsSetting = _settingService.GetSettingByKey("MaxHeightAllowedForMediumThumbnails"); if (maxHieghtAllowedForMediumThumbnailsSetting != null) { maxHieghtAllowedForMediumThumbnailsSetting.ModifiedOn = DateTime.Now; maxHieghtAllowedForMediumThumbnailsSetting.Value = model.MaxHeightAllowedForMediumThumbnails; _settingService.Update(maxHieghtAllowedForMediumThumbnailsSetting); } var maxHieghtAllowedForSmallThumbnailsSetting = _settingService.GetSettingByKey("MaxHeightAllowedForSmallThumbnails"); if (maxHieghtAllowedForSmallThumbnailsSetting != null) { maxHieghtAllowedForSmallThumbnailsSetting.ModifiedOn = DateTime.Now; maxHieghtAllowedForSmallThumbnailsSetting.Value = model.MaxHeightAllowedForSmallThumbnails; _settingService.Update(maxHieghtAllowedForSmallThumbnailsSetting); } var maxHieghtAllowedForSliderThumbnailsSetting = _settingService.GetSettingByKey("MaxHeightAllowedForSliderThumbnails"); if (maxHieghtAllowedForSliderThumbnailsSetting != null) { maxHieghtAllowedForSliderThumbnailsSetting.ModifiedOn = DateTime.Now; maxHieghtAllowedForSliderThumbnailsSetting.Value = model.MaxHeightAllowedForSliderThumbnails; _settingService.Update(maxHieghtAllowedForSliderThumbnailsSetting); } var pictureTypesAllowedSetting = _settingService.GetSettingByKey("PictureTypesAllowed"); if (pictureTypesAllowedSetting != null) { pictureTypesAllowedSetting.ModifiedOn = DateTime.Now; pictureTypesAllowedSetting.Value = string.Join(",", model.SelectedPictureTypes); _settingService.Update(pictureTypesAllowedSetting); } var maxSizeAllowedSetting = _settingService.GetSettingByKey("MaximumSizeAllowed"); if (maxSizeAllowedSetting != null) { maxSizeAllowedSetting.Value = model.MaximumSizeAllowed.ToString(); } } model.Result = "Picture Settings Saved Successfully."; model.ActiveSettings = "PictureSettings"; return(View(model)); } catch { return(View(model)); } }
public ActionResult Settings() { if (!_permissionService.Authorize("ManageSettings")) { return(AccessDeniedView()); } var model = new PictureSettingsModel(); var user = _userContext.CurrentUser; model.ActiveSettings = "PictureSettings"; var maxWidthAllowedForLargeThumbnailsSetting = _settingService.GetSettingByKey("MaxWidthAllowedForLargeThumbnails"); if (maxWidthAllowedForLargeThumbnailsSetting != null) { model.MaxWidthAllowedForLargeThumbnails = maxWidthAllowedForLargeThumbnailsSetting.Value; } var maxWidthAllowedForMediumThumbnailsSetting = _settingService.GetSettingByKey("MaxWidthAllowedForMediumThumbnails"); if (maxWidthAllowedForMediumThumbnailsSetting != null) { model.MaxWidthAllowedForMediumThumbnails = maxWidthAllowedForMediumThumbnailsSetting.Value; } var maxWidthAllowedForSmallThumbnailsSetting = _settingService.GetSettingByKey("MaxWidthAllowedForSmallThumbnails"); if (maxWidthAllowedForSmallThumbnailsSetting != null) { model.MaxWidthAllowedForSmallThumbnails = maxWidthAllowedForSmallThumbnailsSetting.Value; } var maxWidthAllowedForSliderThumbnailsSetting = _settingService.GetSettingByKey("MaxWidthAllowedForSliderThumbnails"); if (maxWidthAllowedForSliderThumbnailsSetting != null) { model.MaxWidthAllowedForSliderThumbnails = maxWidthAllowedForSliderThumbnailsSetting.Value; } var maxHieghtAllowedForLargeThumbnailsSetting = _settingService.GetSettingByKey("MaxHeightAllowedForLargeThumbnails"); if (maxHieghtAllowedForLargeThumbnailsSetting != null) { model.MaxHeightAllowedForLargeThumbnails = maxHieghtAllowedForLargeThumbnailsSetting.Value; } var maxHieghtAllowedForMediumThumbnailsSetting = _settingService.GetSettingByKey("MaxHeightAllowedForMediumThumbnails"); if (maxHieghtAllowedForMediumThumbnailsSetting != null) { model.MaxHeightAllowedForMediumThumbnails = maxHieghtAllowedForMediumThumbnailsSetting.Value; } var maxHieghtAllowedForSmallThumbnailsSetting = _settingService.GetSettingByKey("MaxHeightAllowedForSmallThumbnails"); if (maxHieghtAllowedForSmallThumbnailsSetting != null) { model.MaxHeightAllowedForSmallThumbnails = maxHieghtAllowedForSmallThumbnailsSetting.Value; } var maxHieghtAllowedForSliderThumbnailsSetting = _settingService.GetSettingByKey("MaxHeightAllowedForSliderThumbnails"); if (maxHieghtAllowedForSliderThumbnailsSetting != null) { model.MaxHeightAllowedForSliderThumbnails = maxHieghtAllowedForSliderThumbnailsSetting.Value; } var pictureTypesAllowedSetting = _settingService.GetSettingByKey("PictureTypesAllowed"); if (pictureTypesAllowedSetting != null) { pictureTypesAllowedSetting.Value.TrimEnd(','); model.SelectedPictureTypes = pictureTypesAllowedSetting.Value.Split(','); } var maxSizeAllowedSetting = _settingService.GetSettingByKey("MaximumSizeAllowed"); if (maxSizeAllowedSetting != null) { model.MaximumSizeAllowed = Convert.ToInt32(maxSizeAllowedSetting.Value); } return(View(model)); }
public ActionResult Settings(PictureSettingsModel model) { var user = _userContext.CurrentUser; try { if (ModelState.IsValid) { var pictureSettings = _settingService.GetSettingsByType(SettingTypeEnum.PictureSetting).ToList(); if (pictureSettings.Count > 0) { foreach (var setting in pictureSettings) { setting.ModifiedOn = DateTime.Now; setting.UserId = user.Id; if (setting.Name == "MaxWidthAllowedForLargeThumbnails") { setting.Value = model.MaxWidthAllowedForLargeThumbnails; _settingService.Update(setting); } if (setting.Name == "MaxWidthAllowedForMediumThumbnails") { setting.Value = model.MaxWidthAllowedForMediumThumbnails; _settingService.Update(setting); } if (setting.Name == "MaxWidthAllowedForSmallThumbnails") { setting.Value = model.MaxWidthAllowedForSmallThumbnails; _settingService.Update(setting); } if (setting.Name == "MaxWidthAllowedForSliderThumbnails") { setting.Value = model.MaxWidthAllowedForSliderThumbnails; _settingService.Update(setting); } if (setting.Name == "MaxHeightAllowedForLargeThumbnails") { setting.Value = model.MaxHeightAllowedForLargeThumbnails; _settingService.Update(setting); } if (setting.Name == "MaxHeightAllowedForMediumThumbnails") { setting.Value = model.MaxHeightAllowedForMediumThumbnails; _settingService.Update(setting); } if (setting.Name == "MaxHeightAllowedForSmallThumbnails") { setting.Value = model.MaxHeightAllowedForSmallThumbnails; _settingService.Update(setting); } if (setting.Name == "MaxHeightAllowedForSliderThumbnails") { setting.Value = model.MaxHeightAllowedForSliderThumbnails; _settingService.Update(setting); } } } } model.Result = "Picture Settings Saved Successfully."; model.ActiveSettings = "PictureSettings"; return(View(model)); } catch { return(View(model)); } }