Пример #1
0
 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() });
     }
 }
Пример #2
0
 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));
             }
 }
Пример #3
0
 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());
         }
     }
 }
Пример #4
0
 public SportEventsController(SportEventsContext context)
 {
     _context = context;
 }