public static void AddEvent(TrainingDataEntities entityContext, DateTime timeParam, string athleteParam, string typeParam, TimeSpan swimTimeParam, TimeSpan cycleTimeParam, TimeSpan runTimeParam)
        {
            Event newEvent = new Event()
            {
                Date        = timeParam,
                Athlete     = athleteParam,
                Type        = typeParam,
                SwimTime    = swimTimeParam,
                CycleTime   = cycleTimeParam,
                RunTime     = runTimeParam,
                OverallTime = swimTimeParam + cycleTimeParam + runTimeParam
            };

            entityContext.Events.Add(newEvent);
            try
            {
                entityContext.SaveChanges();
            }
            catch (InvalidOperationException ex)
            {
                //ex.Message;
                throw ex;
            }
            catch (Exception ex)
            {
                // ex.InnerException.Message;
                throw ex;
            }
        }
        public static void DeleteEventByID(TrainingDataEntities entityContext, int keyParam)
        {
            // query for the object that has the specified key
            Event targetEvent = GetEventByID(entityContext, keyParam);

            if (targetEvent != null)
            {
                entityContext.Events.Remove(targetEvent);
                entityContext.SaveChanges();
            }
        }
        public static void UpdateEvent(TrainingDataEntities entityContext, int keyParam, DateTime dateParam, string athleteParam, string typeParam, TimeSpan swimTimeParam, TimeSpan cycleTimeParam, TimeSpan runTimeParam)
        {
            // query for the event with the specified key
            Event targetEvent = GetEventByID(entityContext, keyParam);

            // set the param valuesfor the event
            if (targetEvent != null)
            {
                // update the event object properties
                targetEvent.Date        = dateParam;
                targetEvent.Athlete     = athleteParam;
                targetEvent.Type        = typeParam;
                targetEvent.SwimTime    = swimTimeParam;
                targetEvent.CycleTime   = cycleTimeParam;
                targetEvent.RunTime     = runTimeParam;
                targetEvent.OverallTime = swimTimeParam + cycleTimeParam + runTimeParam;

                entityContext.SaveChanges();
            }
        }