public IEnumerable <string> GetEventById(int eventId) { using (var eventContext = new SportEventsContext()) { var result = eventContext.Events.SingleOrDefault(x => x.EventId == eventId); return(result == null ? new[] { "Empty" } : new[] { result.ToString() }); } }
public IEnumerable <string> GetSports() { using (var eventContext = new SportEventsContext()) using (var sportContext = new SportIdContext()) foreach (var sport in sportContext.Sports) { yield return(sport.Name + " - " + eventContext.Events.Count(x => x.SportId == sport.SportId)); } }
public IEnumerable <string> GetEventsByData(int sportId, string date) { using (var eventContext = new SportEventsContext()) { foreach (var sportEvent in eventContext.Events.Where(x => x.SportId == sportId) .Where(x => x.EventDate.Date == date.ToDateTime().Date)) { yield return(sportEvent.ToString()); } } }
public SportEventsController(SportEventsContext context) { _context = context; }