public async Task CreateNotifications(ModelNotification modelNotifications, string type) { List <Repository.Models.Notification> newNotifications = new List <Repository.Models.Notification>(); List <Task <Repository.Models.Notification> > tasks = new List <Task <Repository.Models.Notification> >(); List <Repository.Models.FollowingUser> allFollowees = await _repo.GetUserFollowees(modelNotifications.Usernameid); foreach (string userid in modelNotifications.Followers) { if (userid != modelNotifications.Usernameid) { tasks.Add(Task.Run(() => Mapper.ModelNotifToRepoNotif(userid, modelNotifications.OtherId, type, null))); } } var results = await Task.WhenAll(tasks); foreach (var item in results) { newNotifications.Add(item); } List <Task> repoTasks = new List <Task>(); foreach (var notification in newNotifications) { await _repo.AddNotification(notification); } List <Repository.Models.Notification> otherNotifications = await Task.Run(() => FolloweeNotifications(modelNotifications.OtherId, type, allFollowees, newNotifications, modelNotifications.Usernameid)); foreach (var notification in otherNotifications) { await _repo.AddNotification(notification); } }
public async Task <ActionResult <bool> > CreateReviewNotification([FromBody] ModelNotification reviewNotification) { if (!ModelState.IsValid) { _logger.LogWarning("UserController.CreateReviewNotification() was called with invalid body data."); return(StatusCode(400)); } await _userLogic.CreateNotifications(reviewNotification, "r"); return(StatusCode(200)); }
public NotificationListPrensenter(INotificationListView view) { _view = view; _model = new ModelNotification(); SubscribeViewToEvents(); }