Beispiel #1
0
 public async Task<JsonResult> ChangeTicketSubscription(int ticketId)
 {
     var userId = Context.SecurityProvider.CurrentUserId;
     var ticket = await Context.Tickets.Include(t => t.TicketSubscribers).Include(t => t.TicketEvents.Select(e => e.TicketEventNotifications)).FirstOrDefaultAsync(t => t.TicketId == ticketId);
     var subscriber =
         ticket.TicketSubscribers.FirstOrDefault(s => s.SubscriberId == Context.SecurityProvider.CurrentUserId);
     var isSubscribed = false;
     if (subscriber == null)
     {
         subscriber = new TicketSubscriber
         {
             SubscriberId = userId,
         };
         ticket.TicketSubscribers.Add(subscriber);
         isSubscribed = true;
     }
     else
     {
         ticket.TicketSubscribers.Remove(subscriber);
     }
     await Context.SaveChangesAsync();
     return new JsonCamelCaseResult { Data = new { IsSubscribed = isSubscribed } };
 }
Beispiel #2
0
 public static UserDisplayInfo GetSubscriberDisplayInfo(this TicketSubscriber subscriber)
 {
     return(GetUserInfo(subscriber.SubscriberId));
 }