Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        public void Notify(Notification notification)
        {
            var userNotification = new UserNotification(this, notification);

            UserNotifications.Add(userNotification);
        }
Exemplo n.º 3
0
 public void Notify(Notification notification)
 {
     UserNotification.Add(new UserNotification(this, notification));
 }