public async Task ProcessMessage(string user, string senderClientId, Message message) { var recipients = GetRecipients(message.Recipients); foreach (var recipient in recipients) { var notification = _factory.CreateNotification(message, user, recipient); await _repository.Add(notification); var notificationDto = _factory.CreateNotification(notification); //await _notificationHub.Clients.All.Notify(notificationDto); await _notificationHub.Clients.AllExcept(senderClientId).Notify(notificationDto); } }
private void OnGetNotification(NotificationDto notification) { if (State == ConnectionState.Connected) { RecievedNotificationEvent?.Invoke(_factory.CreateNotification(notification)); } }
public async Task <Notification> CheckWorkshiftForNotification(Workshift workshift) { var currentDate = DateTime.Now; if (workshift.StartDateTime.Day != currentDate.Day) { return(null); } var contract = await _contractService.GetContractByWorkshiftId(workshift.Id); if (currentDate - workshift.StartDateTime >= TimeSpan.FromMinutes(10) && workshift.State.GetType() == typeof(NoState)) { var notification = _notificationFactory.CreateNotification(contract.Employer, contract.Person, "NotStarted", workshift.Job, currentDate); if (await _notificationRepository.CheckNotificationIfExist(notification)) { return(null); } return(notification); } if (workshift.State.GetType() != typeof(PausedState)) { return(null); } if (currentDate - workshift.WorkedTimeblocks.Last().StopTime >= TimeSpan.FromMinutes(70)) { return(_notificationFactory.CreateNotification(contract.Employer, contract.Person, "Paused", workshift.Job, currentDate)); } return(null); }