public IActionResult FeedSigned(HttpResponse response, HttpSession session, ShoutBindingModel sbm) { var user = this.data.LoginRepository.FindUserByLogin(session.Id); var shout = new Shout() { Author = user, Content = sbm.Content, PostedOn = DateTime.Now }; if (sbm.Lifetime != 0) { shout.Lifetime = new TimeSpan(sbm.Lifetime, 59, 59); } var notification = new Notification() { ShoutAuthor = user }; var followedBy = this.data.UsersRepository.Find(u => u.Following.Select(f => f.Id).Contains(user.Id)); foreach (var follower in followedBy) { follower.Notifications.Add(notification); } this.data.ShoutRepository.Insert(shout); this.data.SaveChanges(); Redirect(response, "/home/feedSigned"); return(null); }
public IActionResult Feed(HttpResponse response, ShoutBindingModel sbm) { var shout = this.data.ShoutRepository.FindByPredicate(s => s.Content == sbm.Content); this.data.ShoutRepository.Delete(shout); this.data.SaveChanges(); Redirect(response, "/user/feed"); return(null); }