public IHttpActionResult Cancel(int id) { var userId = User.Identity.GetUserId(); var gig = _context.Gigs.Single(g => g.Id == id && g.ArtistId == userId); if (gig.IsCanceled) return NotFound(); gig.IsCanceled = true; var notification = new Notification { DateTime = DateTime.Now, Gig = gig, Type = NotificationType.GigCanceled }; var attendees = _context.Attendances .Where(a => a.GigId == gig.Id) .Select(a => a.Attendee) .ToList(); foreach (var attendee in attendees) { var userNotification = new UserNotification { User = attendee, Notification = notification }; _context.UserNotifications.Add(userNotification); } _context.SaveChanges(); return Ok(); }
public void Notify(Notification notification) { var userNotification = new UserNotification(this, notification); UserNotifications.Add(userNotification); }
public void Notify(Notification notification) { UserNotification.Add(new UserNotification(this, notification)); }