public ActionResult Index() { var db = new EventDbContext(); var events = db.Events.ToList(); m.Events = events; m.Events = new List <Event>(); m.Events.AddRange(db.GetEvents()); m.Event = new Event(); m.Event.Date = DateTime.Now; return(View(m)); }
public ActionResult Participants(int id) { var db = new EventDbContext(); m.PaymentMethods = db.GetPaymentMethods(); var events = db.GetEvents(); foreach (Event e in events) { if (e.Id == id) { m.SelectedEventId = id; m.Event = e; break; } } m.Companies = db.GetCompanies(); m.Persons = db.GetPersons(); m.Participants = new List <Participant>(); foreach (Company c in m.Companies) { if (c.Active == false || c.EventId != m.SelectedEventId) { continue; } Participant p = new Participant(); p.TypeName = "Company"; p.Name = c.Name; p.Number = c.RegistryNumber; p.RegisterDate = c.RegisterDate; p.ParticipantId = c.Id; m.Participants.Add(p); } foreach (Person n in m.Persons) { if (n.Active == false || n.EventId != m.SelectedEventId) { continue; } Participant p = new Participant(); p.TypeName = "Person"; p.Name = n.FirstName + " " + n.LastName; p.Number = n.PersonalCode; p.RegisterDate = n.RegisterDate; p.ParticipantId = n.Id; m.Participants.Add(p); } m.Participants = m.Participants.OrderByDescending(o => o.RegisterDate).ToList(); return(View(m)); }