public Event SaveNewEvent(Event comp)
        {
            using (var connection = new EntityConnection("name=CoreContainer"))
            {
                _core = new CoreContainer(connection);

                _core.Events.AddObject(comp);
                _core.SaveChanges();
            }

            return comp;
        }
        public Event UpdateEvent(Event comp)
        {
            using (var connection = new EntityConnection("name=CoreContainer"))
            {
                _core = new CoreContainer(connection);

                _core.Events.Attach(_core.Events.Single(s => s.EventId == comp.EventId));

                _core.Events.ApplyCurrentValues(comp);

                _core.SaveChanges();
            }

            return comp;
        }
        public Event GetEventById(int eventId)
        {
            var comp = new Event();

            using (var connection = new EntityConnection("name=CoreContainer"))
            {
                _core = new CoreContainer(connection);

                comp = _core.Events
                            .Include("Results.Scores")
                            .Include("Results.Driver")
                            .Include("Series.SeriesClasses.Class")
                            .Where(e => e.EventId == eventId)
                            .FirstOrDefault();
            }

            return comp;
        }
        public EventViewModel SaveNewEvent(EventViewModel model)
        {
            var comp = new Event
            {
                Name = model.Name,
                Date = model.Date,
                ClubId = model.ClubId,
                SeriesId = model.SeriesId,
                LocationId = model.LocationId,
                EventTypeId = model.EventTypeId,
                NumberOfCourses = model.NumberOfCourses,
                DateCreated = DateTime.Now
            };

            _eventRepository.SaveNewEvent(comp);

            return model;
        }
        /* WHAT IT IS ON WPaC PAGE
            1	 Mike King (StIcK kInG)			28	28	 56
            2	 Chris Lengyel (DrCrawlGood)	36	30	 66
            3	 Carey Baird (Eviltwin v2)		38	28	 66
            4	 Mike Young (onespeeder)		38	28	 66
            5	 Bill Goff (ovalman)			38	30	 68
            6	 Del Anderson (DRCMan)			32	38	 70

            WHAT IT SHOULD BE
            1	 Mike King (StIcK kInG)			28	28	 56
            2	 Carey Baird (Eviltwin v2)		38	28	 66
            3	 Mike Young (onespeeder)		38	28	 66
            4	 Chris Lengyel (DrCrawlGood)	36	30	 66
            5	 Bill Goff (ovalman)			38	30	 68
            6	 Del Anderson (DRCMan)			32	38	 70
        */
        private IList<Result> CreateResultSet(int numberResults, int numberOfCourses)
        {
            var results = new List<Result>();

            for (int i = 0; i < numberResults; i++)
            {
                var comp = new Event
                           	{
                           		NumberOfCourses = numberOfCourses
                           	};

                var result = new Result
                {
                    ResultId = (i + 10),
                    ClassId = 2,
                    EventId = 3,
                    DriverId = (i + 1),
                    Event = comp
                };

                results.Add(result);
            }

            return results;
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Events EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToEvents(Event @event)
 {
     base.AddObject("Events", @event);
 }
 /// <summary>
 /// Create a new Event object.
 /// </summary>
 /// <param name="eventId">Initial value of the EventId property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="eventTypeId">Initial value of the EventTypeId property.</param>
 /// <param name="clubId">Initial value of the ClubId property.</param>
 /// <param name="locationId">Initial value of the LocationId property.</param>
 /// <param name="date">Initial value of the Date property.</param>
 /// <param name="dateCreated">Initial value of the DateCreated property.</param>
 /// <param name="numberOfCourses">Initial value of the NumberOfCourses property.</param>
 public static Event CreateEvent(global::System.Int32 eventId, global::System.String name, global::System.Int32 eventTypeId, global::System.Int32 clubId, global::System.Int32 locationId, global::System.DateTime date, global::System.DateTime dateCreated, global::System.Int32 numberOfCourses)
 {
     Event @event = new Event();
     @event.EventId = eventId;
     @event.Name = name;
     @event.EventTypeId = eventTypeId;
     @event.ClubId = clubId;
     @event.LocationId = locationId;
     @event.Date = date;
     @event.DateCreated = dateCreated;
     @event.NumberOfCourses = numberOfCourses;
     return @event;
 }