public async Task <IActionResult> NotificationSettings(NotificationSettingsViewModel vm, string command) { var user = await _userManager.GetUserAsync(User); if (command == "disable-all") { user.DisabledNotifications = "all"; } else if (command == "enable-all") { user.DisabledNotifications = ""; } else if (command == "update") { var disabled = vm.DisabledNotifications.Where(item => item.Selected).Select(item => item.Value) .ToArray(); user.DisabledNotifications = disabled.Any() is true ? string.Join(';', disabled) + ";" : string.Empty; } await _userManager.UpdateAsync(user); TempData.SetStatusMessageModel(new StatusMessageModel() { Message = "Updated successfully.", Severity = StatusMessageModel.StatusSeverity.Success }); return(RedirectToAction("NotificationSettings")); }
public async Task <ActionResult> NotificationSettings(NotificationSettingsViewModel model) { await _accountOrchestrator.UpdateNotificationSettings(model); SetInfoMessage("Settings updated", FlashMessageSeverityLevel.Info); return(RedirectToAction("NotificationSettings")); }
public NotificationSettings(NotificationSetting setting) { InitializeComponent(); BackgroundColor = Color.Transparent; this.BindingContext = viewModel = new NotificationSettingsViewModel(setting); SetupClicks(); }
public IActionResult Notification() { var settings = _blogConfig.NotificationSettings; var vm = new NotificationSettingsViewModel { EmailDisplayName = settings.EmailDisplayName, EnableEmailSending = settings.EnableEmailSending, SendEmailOnCommentReply = settings.SendEmailOnCommentReply, SendEmailOnNewComment = settings.SendEmailOnNewComment }; return(View(vm)); }
public void OnGet() { var settings = _blogConfig.NotificationSettings; ViewModel = new() { EmailDisplayName = settings.EmailDisplayName, EnableEmailSending = settings.EnableEmailSending, SendEmailOnCommentReply = settings.SendEmailOnCommentReply, SendEmailOnNewComment = settings.SendEmailOnNewComment }; } }
public async Task UpdateNotificationSettings(NotificationSettingsViewModel model) { var setting = model.NotificationSettings.First(); _logger.Info($"Uppdating setting for user {setting.UserRef}"); await _mediator.Send(new UpdateUserNotificationSettingsCommand { UserRef = setting.UserRef, ReceiveNotifications = setting.ReceiveNotifications }); _logger.Trace($"Updated receive notification to {setting.ReceiveNotifications} for user {setting.UserRef}"); }
public async Task GetsInitialisedToTheProperValue(bool permissionGranted) { var observer = TestScheduler.CreateObserver <bool>(); PermissionsService.NotificationPermissionGranted.Returns(Observable.Return(permissionGranted)); var viewModel = new NotificationSettingsViewModel(NavigationService, BackgroundService, PermissionsService, UserPreferences); viewModel.PermissionGranted.Subscribe(observer); await viewModel.Initialize(); observer.Messages.First().Value.Value.Should().Be(permissionGranted); }
public ActionResult Settings(NotificationSettingsViewModel model) { if (ModelState.IsValid) { var userId = _authService.CurrentUser.Id; var selectedNotifications = model.NotificationTypes .ToDictionary(x => x.NotificationType.Id, x => x.SelectedKinds.Aggregate(NotificationKind.None, (c, n) => c |= n)); _userService.UpdateNotificationSettings(userId, selectedNotifications); return(RedirectToAction("Settings")); } return(View(model)); }
public async Task TheMySettingsAreUpdated() { //Arrange _owinWrapper.Setup(x => x.GetClaimValue("sub")).Returns("TEST"); var payload = new NotificationSettingsViewModel(); //Act await _controller.NotificationSettings(payload); //Assert _orchestrator.Verify(x => x.UpdateNotificationSettings( It.Is <string>(userRef => userRef == "TEST"), It.IsAny <List <UserNotificationSetting> >()), Times.Once); }
public async Task <ActionResult> NotificationSettings(NotificationSettingsViewModel vm) { var userIdClaim = OwinWrapper.GetClaimValue(ControllerConstants.UserRefClaimKeyName); await _userSettingsOrchestrator.UpdateNotificationSettings(userIdClaim, vm.NotificationSettings); var flashMessage = new FlashMessageViewModel { Severity = FlashMessageSeverityLevel.Success, Message = "Settings updated." }; AddFlashMessageToCookie(flashMessage); return(RedirectToAction(ControllerConstants.NotificationSettingsActionName)); }
// // GET: /Profile/Settings public ActionResult Notifications() { UserProfile profile = CurrentUserProfileOrThrow; NotificationSettingsViewModel viewModel = new NotificationSettingsViewModel() { AllowUsersToSendSiteMessages = profile.AllowUsersToSendSiteMessages, Email = profile.Email, NotifyAllWhenLoggedOn = profile.NotifyAllWhenLoggedOn, NotifyOfSiteUpdatesToEmail = profile.NotifyOfSiteUpdatesToEmail, SendSiteMessagesToEmail = profile.SendSiteMessagesToEmail, SendSiteMessagesToSms = profile.SendSiteMessagesToSms, SubscribeToNewsletterEmail = profile.SubscribeToNewsletterEmail, UserProfile = profile }; return(View(viewModel)); }
public ActionResult Notifications(NotificationSettingsViewModel model) { UserProfile profile = CurrentUserProfileOrThrow; profile.AllowUsersToSendSiteMessages = model.AllowUsersToSendSiteMessages; profile.NotifyAllWhenLoggedOn = model.NotifyAllWhenLoggedOn; profile.NotifyOfSiteUpdatesToEmail = model.NotifyOfSiteUpdatesToEmail; profile.SendSiteMessagesToEmail = model.SendSiteMessagesToEmail; profile.SendSiteMessagesToSms = model.SendSiteMessagesToSms; profile.SubscribeToNewsletterEmail = model.SubscribeToNewsletterEmail; GStoreDb.UserProfiles.Update(profile); GStoreDb.SaveChanges(); GStoreDb.LogUserActionEvent(HttpContext, RouteData, this, UserActionCategoryEnum.Profile, UserActionActionEnum.Profile_UpdateNotifications, "", true); return(RedirectToAction("Index")); }
public async Task <BaseModel> SaveAsync(NotificationSettingsViewModel model) { var userData = await _unitOfWork.UserLoginRepository.GetByID(model.UserId); if (userData == null) { userData = null; return(new BaseModel { Status = false, Messsage = UMessagesInfo.Error }); } var result = await _unitOfWork.UserNotificationSettingsRepository.FindAllBy(c => c.User.Id == model.UserId); var notificationData = result.FirstOrDefault(); if (notificationData == null) { //insert await _unitOfWork.UserNotificationSettingsRepository.Insert(new UserNotificationSettingsDataModel { BlogSubscription = model.BlogSubscription, Comments = model.Comments, Followis = model.Followis, Like = model.Like, UpdatedBy = model.UserId, CreatedBy = model.UserId, AddedDate = DateTime.Now, User = userData }); } else { notificationData.BlogSubscription = model.BlogSubscription; notificationData.Comments = model.Comments; notificationData.Followis = model.Followis; notificationData.Like = model.Like; notificationData.UpdatedBy = model.UserId; //update await _unitOfWork.UserNotificationSettingsRepository.Update(notificationData); } return(new BaseModel { Status = true, Messsage = UMessagesInfo.RecordSaved }); }
public ActionResult Settings() { var userId = _authService.CurrentUser.Id; var settings = _userService.GetNotificationSettings(userId); var types = _userService.GetNotificationTypes(); var model = new NotificationSettingsViewModel { NotificationTypes = types.Select(x => new NotificationTypeViewModel { NotificationType = x, CurrentKind = settings.Where(s => s.NotificationTypeId == x.Id) .Select(s => s.NotificationKinds)?.FirstOrDefault() ?? NotificationKind.None }) .ToList() }; return(View(model)); }
public async Task <NotificationSettingsViewModel> GetNotificationSettings(string userRef) { _logger.Info($"Getting setting for user {userRef}"); var response = await _mediator.Send(new GetUserNotificationSettingsQuery { UserRef = userRef }); var model = new NotificationSettingsViewModel { HashedId = "ABBA12", NotificationSettings = Map(response.NotificationSettings) }; _logger.Trace($"Found {response.NotificationSettings.Count} settings for user {userRef}"); return(model); }
public async Task <IActionResult> Notification(NotificationSettingsViewModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var settings = _blogConfig.NotificationSettings; settings.EmailDisplayName = model.EmailDisplayName; settings.EnableEmailSending = model.EnableEmailSending; settings.SendEmailOnCommentReply = model.SendEmailOnCommentReply; settings.SendEmailOnNewComment = model.SendEmailOnNewComment; await _blogConfig.SaveAsync(settings); await _blogAudit.AddAuditEntry(EventType.Settings, AuditEventId.SettingsSavedNotification, "Notification Settings updated."); return(Ok()); }
public async Task <IActionResult> Notification(NotificationSettingsViewModel model) { if (ModelState.IsValid) { var settings = _blogConfig.NotificationSettings; settings.AdminEmail = model.AdminEmail; settings.EmailDisplayName = model.EmailDisplayName; settings.EnableEmailSending = model.EnableEmailSending; settings.SendEmailOnCommentReply = model.SendEmailOnCommentReply; settings.SendEmailOnNewComment = model.SendEmailOnNewComment; var response = await _blogConfig.SaveConfigurationAsync(settings); _blogConfig.RequireRefresh(); Logger.LogInformation($"User '{User.Identity.Name}' updated EmailSettings"); await _moongladeAudit.AddAuditEntry(EventType.Settings, Auditing.AuditEventId.SettingsSavedNotification, "Notification Settings updated."); return(Json(response)); } return(Json(new FailedResponse((int)ResponseFailureCode.InvalidModelState, "Invalid ModelState"))); }
public async Task <IActionResult> Notification(NotificationSettingsViewModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var settings = _blogConfig.NotificationSettings; settings.AdminEmail = model.AdminEmail; settings.EmailDisplayName = model.EmailDisplayName; settings.EnableEmailSending = model.EnableEmailSending; settings.SendEmailOnCommentReply = model.SendEmailOnCommentReply; settings.SendEmailOnNewComment = model.SendEmailOnNewComment; await _blogConfig.SaveConfigurationAsync(settings); _blogConfig.RequireRefresh(); _logger.LogInformation($"User '{User.Identity.Name}' updated EmailSettings"); await _blogAudit.AddAuditEntry(EventType.Settings, AuditEventId.SettingsSavedNotification, "Notification Settings updated."); return(Ok()); }
public NotificationSettingsView() { InitializeComponent(); DataContext = new NotificationSettingsViewModel(); }
public NotificationSettingsSteps(RoomContext context) { _context = context; _vm = context.SettingsViewModel.SettingsViewModels.OfType <NotificationSettingsViewModel>().First(); }
public NotificationSettingsPage(Deck Deck) { InitializeComponent(); BindingContext = new NotificationSettingsViewModel(Deck); }
public async Task <IActionResult> Settings(NotificationSettingsViewModel model) { model.UserId = _claimAccessor.UserId; return(Json(await _notificationSettingsService.SaveAsync(model))); }
public async Task UpdateNotificationSettings(NotificationSettingsViewModel settingsVm) { var mapper = new AutoMapper.MapperConfiguration(cfg => cfg.CreateMap <NotificationSettingsViewModel, NotificationSettings>()).CreateMapper(); var settingsToUpdate = mapper.Map <NotificationSettingsViewModel, NotificationSettings>(settingsVm); await _notificationSettingsRepository.Update(settingsToUpdate); }