Exemple #1
0
        public void AddParticipantsToEvent(string friends, int eventId)
        {
            var myEvent = GetEventById(eventId);

            try
            {
                var FriendIds = friends.Split(',');
                foreach (var userId in FriendIds)
                {
                    if (myEvent.ParticipantsInEvent.Where(p => p.UserId == Convert.ToInt32(userId)).Count() == 0)
                    {
                        ParticipantsInEvent.Add(new ParticipantsInEvent
                        {
                            EventId = eventId,
                            UserId  = Convert.ToInt32(userId)
                        });
                    }
                }
                ;

                SaveChanges();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Exemple #2
0
 public void AddLoggedInUserToEvent(int currentUserId, int eventId)
 {
     ParticipantsInEvent.Add(new ParticipantsInEvent
     {
         EventId = eventId,
         UserId  = currentUserId,
     });
     SaveChanges();
 }