Esempio n. 1
0
 public int AddGuestsToEvent(int eventId, List <GuestDTO> guests)
 {
     foreach (var guest in guests)
     {
         var           dataGuest  = guestRepo.Get(e => e.FirstName == guest.FirstName && e.LastName == guest.LastName && e.Phone == guest.Phone).Select(g => g.Id).FirstOrDefault();
         EventGuestDTO eventGuest = null;
         if (dataGuest == 0)
         {
             var guestID = guestService.CreateGuest(guest);
             eventGuest = new EventGuestDTO
             {
                 EventId = eventId,
                 GuestId = guestID
             };
         }
         else
         {
             eventGuest = new EventGuestDTO
             {
                 EventId = eventId,
                 GuestId = dataGuest
             };
         }
         var newEventGuest = (EventGuest) new EventGuest().InjectFrom(eventGuest);
         eventGuestRepo.Add(newEventGuest);
         unitOfWork.Commit();
     }
     return(0);
 }
 public void RemoveGuest(EventGuestDTO guest)
 {
     _context.Clients.All.removeGuest(guest.Name, guest.GuestID, guest.Host.Name,
                                      guest.Host.UserID, guest.EventID.ToString());
 }