internal bool CheckIfUserIsParticipant(int userId, int eventId) { if (ParticipantsInEvent.Where(p => p.UserId == userId && p.EventId == eventId).Count() > 0) { return(true); } else { return(false); } }
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); }
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); }
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); }