public async Task <IActionResult> SendNotification(NotificationModel model) { var notificationTemplate = _notificationTemplateService.GetNotificationTemplate(model.NotificationType); var notificationEntityParams = new NotificationEntityParams() { ImagePath = notificationTemplate.ImagePath, CreatedDate = DateTime.Now, IsActionTaken = false, NotificationType = model.NotificationType, UserId = model.UserId, GameId = model.GameId, CreditsToEarn = model.CreditsToEarn, UserCredits = model.UserCredits, WinStreakCount = model.WinStreakCount }; switch (model.NotificationType) { case ServiceBase.Enums.NotificationType.WatchAdNotification: notificationEntityParams.Label = notificationTemplate.Label.Replace("{UserCredits}", model.UserCredits.ToString()); notificationEntityParams.Description = notificationTemplate.Description.Replace("{WatchingAdCreditReward}", model.CreditsToEarn.ToString()); break; case ServiceBase.Enums.NotificationType.UpgradeToProNotification: notificationEntityParams.Label = notificationTemplate.Label.Replace("{UserCredits}", model.UserCredits.ToString()); notificationEntityParams.Description = notificationTemplate.Description.Replace("{UpgradeToProCreditReward}", model.CreditsToEarn.ToString()); break; case ServiceBase.Enums.NotificationType.StreakNotification: notificationEntityParams.Label = notificationTemplate.Label.Replace("{CreditsToEarn}", model.CreditsToEarn.ToString()); notificationEntityParams.Description = notificationTemplate.Description.Replace("{WinStreakCount}", model.WinStreakCount.ToString()); break; default: notificationEntityParams.Label = notificationTemplate.Label; notificationEntityParams.Description = notificationTemplate.Description; break; } _notificationService.CreateOrUpdate(notificationEntityParams); var notificationModel = _mapper.Map <NotificationModel>(notificationEntityParams); await _hubContext.Clients.User(model.UserId).ReceiveNotification(notificationModel); return(Ok(true)); }