Пример #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);
            }
        }
Пример #2
0
 public void AddLoggedInUserToEvent(int currentUserId, int eventId)
 {
     ParticipantsInEvent.Add(new ParticipantsInEvent
     {
         EventId = eventId,
         UserId  = currentUserId,
     });
     SaveChanges();
 }
Пример #3
0
 internal bool CheckIfUserIsParticipant(int userId, int eventId)
 {
     if (ParticipantsInEvent.Where(p => p.UserId == userId && p.EventId == eventId).Count() > 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Пример #4
0
        internal List <User> GetUsersByEventId(int id)
        {
            var participants = ParticipantsInEvent.Where(e => e.EventId == id).ToList();
            var users        = new List <User>();

            foreach (var participant in participants)
            {
                users.Add(User.Where(u => u.Id == participant.UserId).First());
            }
            return(users);
        }
Пример #5
0
        public Event GetEventById(int id)
        {
            var myEvent = Event.Where(e => e.Id == id).First();

            myEvent.ParticipantsInEvent = ParticipantsInEvent.Where(p => p.EventId == myEvent.Id).ToList();

            myEvent.StandardCurrency = Currency.Where(c => c.Id == myEvent.StandardCurrencyId).FirstOrDefault();

            myEvent.Expense = Expense.Where(e => e.EventId == myEvent.Id).ToList();

            foreach (var expense in myEvent.Expense)
            {
                expense.PayersForExpense = PayersForExpense.Where(p => p.ExpenseId == expense.Id).ToList();
            }

            foreach (var person in myEvent.ParticipantsInEvent)
            {
                person.User = User.Where(u => u.Id == person.UserId).First();
            }

            return(myEvent);
        }
Пример #6
0
        public List <Event> GetInactiveEventsByUserId(int id)
        {
            var myEvents = ParticipantsInEvent.Where(p => p.UserId == id && p.Event.IsActive == false).Select(p => p.Event).ToList();

            return(myEvents);
        }