public async Task SendOutCustomNotification(NewNotificationDTO dto) { foreach (var user in dto.Players) { var notification = new DAL.App.DTO.Notification { Title = dto.Title, Content = dto.Content, AppUserId = user.Id, NotificationType = "View", TrainingId = null }; notification = ServiceRepository.AddNewNotification(notification); sendOutNotification(notification, user); } await ServiceUnitOfWork.SaveChangesAsync(); }
public async Task <NotificationDTO> Create(NewNotificationDTO notification) { if (notification == null) { throw new ArgumentNullException(nameof(notification)); } var entity = _mapper.Map <Notification>(notification); var additionResult = await _context.Notifications.AddAsync(entity); await _context.SaveChangesAsync(); var createdEntity = await _context.Notifications.FindAsync(additionResult.Entity.Id); var dto = _mapper.Map <NotificationDTO>(createdEntity); _producer.Send(JsonConvert.SerializeObject(dto, CamelCaseProperties), createdEntity.GetType().Name); return(dto); }
public async Task PostNotification(NewNotificationDTO notification) { await bll.NotificationService.SendOutCustomNotification(notification); }
public async Task <NotificationDTO> Create(NewNotificationDTO notification) { return(await _notificationsService.Create(notification)); }