Example #1
0
        /// <summary>
        /// This method generate Schools an Training Sessions
        /// </summary>
        /// <returns></returns>
        public int GenerateSchoolTrainingSessions()
        {
            Random random = new Random();
            School school = new School()
            {
                SchoolId               = Game.Schools.Count + 1,
                SchoolName             = schoolsNames[random.Next(schoolsNames.Count)],
                SchoolTrainingSessions = new List <TrainingSession>(),
                ImageUrl               = schoolsImages[random.Next(schoolsImages.Count)]
            };

            for (int index = 0; index < random.Next(1, 3); index++)
            {
                Skill           skill           = Game.Skills[random.Next(Game.Skills.Count)];
                int             sessionDuration = skill.SkillLevel + 1;
                string          sessionName     = "Formation " + skill.SkillName;
                TrainingSession trainingSession = new TrainingSession()
                {
                    Accessibility             = true,
                    TrainingSessionDevelopers = new List <Developer>(),
                    TrainingSessionDuration   = sessionDuration,
                    TrainingSessionId         = school.SchoolTrainingSessions.Count + 1,
                    TrainingSessionSkill      = skill,
                    Name   = sessionName,
                    School = school
                };

                school.SchoolTrainingSessions.Add(trainingSession);
            }
            Game.Schools.Add(school);
            return(Game.Schools.Count);
        }
Example #2
0
        public static TrainingSession CreateEffortTrainingData(DateTime initial, int i,
                                                               TrainingSessionMeasurmentDataRepository
                                                               trainingSessionMeasurmentDataRepository,
                                                               TrainingSessionCommentsRepository
                                                               trainingSessionCommentsRepository, int userId)
        {
            GenericError error;

            DateTime currentDay = initial.AddDays(i);
            var      session    = new TrainingSession
            {
                UserId            = userId,
                TrainingSessionId = Guid.NewGuid(),
                EffortId          = ((i + 2) % 3 + 1),
                TrainingTypeId    = (i % 6) + 1,
                SportId           = 2,
                DateTrainingEnd   = currentDay.AddHours(2),
                DateTrainingStart = currentDay,
            };


            var sessionMeasurmentData = new TrainingSessionMeasurmentData
            {
                TrainingSessionId = session.TrainingSessionId,
                UserId            = session.UserId,
            };

            trainingSessionMeasurmentDataRepository.InsertEntity(out error, sessionMeasurmentData);


            return(session);
        }
Example #3
0
        public void TestLoadSessionCycling()
        {
            FileReader     f         = new FileReader();
            string         path      = @"C:\own\programming\projects\TrainingAnalysisFull\TrainingAnalysisGUI\sessions\Petter_Stenhagen_2019-07-30_17-02-02.tcx";
            string         session   = f.readFile(path);
            string         startTime = TrainingSession.getHeaderInfo(session)["startTime"];
            CyclingSession cs        = new CyclingSession(startTime);
            bool           success   = cs.loadSessionBody(session);

            Assert.IsTrue(success);
            Assert.AreEqual(2516, cs.mTimeVector.Count);

            // First
            Assert.AreEqual(0, cs.mTimeVector[0]);
            Assert.IsNull(cs.mPosVector[0]);
            DoubleWithinMargin(TrainingSession.AltError, cs.mAltVector[0], 0.000001);
            DoubleWithinMargin(TrainingSession.DistError, cs.mDistVector[0], 0.000001);
            Assert.AreEqual(TrainingSession.HRError, cs.mHRVector[0]);

            // next to last
            int i = 2514;

            Assert.AreEqual(i, cs.mTimeVector[i]);
            DoubleWithinMargin(58.52981167, cs.mPosVector[i].mLatitude, 0.000001);
            DoubleWithinMargin(15.45538167, cs.mPosVector[i].mLongitude, 0.000001);
            DoubleWithinMargin(70.562, cs.mAltVector[i], 0.000001);
            DoubleWithinMargin(18551, cs.mDistVector[i], 0.000001);
            Assert.AreEqual(TrainingSession.HRError, cs.mHRVector[i]);
        }
        public async Task <ActionResult> Post([FromBody] TrainingSession session)
        {
            var procedure = "web.post_trainingsession";

            try
            {
                using (var conn = new SqlConnection(_config.GetConnectionString("DefaultConnection"))) {
                    DynamicParameters parameters = new DynamicParameters();

                    var jsonParameters = JsonSerializer.Serialize(session);
                    parameters.Add("Json", jsonParameters);

                    var qr = await conn.ExecuteScalarAsync <string>(
                        sql : procedure,
                        param : parameters,
                        commandType : CommandType.StoredProcedure
                        );
                };
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Cannot save training sessions");

                return(new StatusCodeResult(500));
            }

            return(new OkResult());
        }
Example #5
0
        public static void SeedTrainingData(List <int> userIds, DateTime now, int effortId, int trainigTypeId,
                                            int days = 1)
        {
            GenericError error;
            var          trainingDataRepository = new TrainingSessionsRepository();
            var          trainingSessionMeasurmentDataRepository = new TrainingSessionMeasurmentDataRepository();

            trainingDataRepository.Drop();
            trainingSessionMeasurmentDataRepository.Drop();

            userIds.ForEach(userId =>
            {
                DateTime initial = now.AddDays(-days);
                for (int i = 0; i < days; i++)
                {
                    TrainingSession session = CreateEffortTrainingData(initial, i,
                                                                       trainingSessionMeasurmentDataRepository, null,
                                                                       userId);
                    session.TrainingTypeId = trainigTypeId;
                    session.EffortId       = effortId;

                    trainingDataRepository.InsertEntity(out error, session);
                }
            });
        }
        // For each exericise add it to the database
        private void buttonSave_Click(object sender, EventArgs e)
        {
            // TODO: This

            // Save user entered values as a new trainingSession
            string name        = textBoxName.Text;
            string description = textBoxDescription.Text;
            string sets        = textBoxTrainingSessionSets.Text;
            string reps        = textBoxTrainingSessionReps.Text;
            string active      = checkBoxActive.Checked.ToString();

            TrainingSession newSession = new TrainingSession(name, description, sets, reps, active);

            // Convert the object to JSON
            string jsonSession = JsonConvert.SerializeObject(newSession);

            logger.Info(jsonSession);
            // Insert it into the database
            string sessionId = AddTrainingSessionTodatabase(jsonSession);

            MessageBox.Show(sessionId);

            // Get the ID back from the tool
            // Returning JSON should contain trainingSessionId: VALUE

            // For each exercise in trainingsesisonexercise
            // Get exercise id and trainingsession ID
            // Sent POST request to api endpoint
            // Handle response for each request
        }
Example #7
0
    //Zurückgeben der besten TrainingsSession auf dem ausgewählten course
    public TrainingSession GetBestSessionByCourse(string courseId)
    {
        List <TrainingSession> sessionsOnCourse = new List <TrainingSession>();

        foreach (TrainingSession session in trainingSessions)
        {
            if (session.courseId == courseId)
            {
                sessionsOnCourse.Add(session);
            }
        }

        if (sessionsOnCourse.Count != 0)
        {
            TrainingSession bestTrainingSession = sessionsOnCourse[0];
            int             bestFitness         = sessionsOnCourse[0].GetLastGeneration().GetBestIndividualFitness();

            for (int i = 1; i < sessionsOnCourse.Count; i++)
            {
                int fitness = sessionsOnCourse[i].GetLastGeneration().GetBestIndividualFitness();
                if (fitness > bestFitness)
                {
                    bestTrainingSession = sessionsOnCourse[i];
                    bestFitness         = fitness;
                }
            }

            return(bestTrainingSession);
        }

        return(null);
    }
Example #8
0
        public static IEnumerable <TrainingSession> GetInitSession()
        {
            var sessions = new List <TrainingSession>();

            for (var i = 0; i < 100; i++)
            {
                var session = new TrainingSession()
                {
                    Name        = $"Test Session {i+1}",
                    DateCreated = DateTime.UtcNow
                };

                var drill = new Drill()
                {
                    Description = "Defensive Skills",
                    Name        = "Defense",
                    Duration    = 20,
                    DateCreated = DateTime.UtcNow
                };
                session.AddDrill(drill);
                sessions.Add(session);
            }

            return(sessions);
        }
Example #9
0
        private static IList <TrainingSession> GetSessions(string location)
        {
            var sr = new StreamReader(location);

            var    sessionList = new List <TrainingSession>();
            string s           = sr.ReadLine();

            while (s != null)
            {
                var split = s.Split(',');

                var newTrainingSession = new TrainingSession
                {
                    SessionFee      = double.Parse(split[0]),
                    SessionCapacity = uint.Parse(split[1]),
                    CourseId        = new ForeignKeys().GetRandomCourse()
                };

                sessionList.Add(newTrainingSession);

                s = sr.ReadLine();
            }

            return(sessionList);
        }
Example #10
0
        public void StartTraining(string userID, int languageID)
        {
            var cards = unit.TrainingRepository
                        .GetTrainableFlashcards(userID, languageID, count: 5);

            if (cards.Count == 0)
            {
                return;
            }

            var training = new TrainingSession()
            {
                DateStarted = DateTime.Now,
                LanguageID  = languageID,
                UserID      = userID
            };

            foreach (var card in cards)
            {
                training.TrainingCards.Add(new TrainingCard()
                {
                    FlashcardID       = card.ID,
                    InternalLossCount = 0
                });
            }

            unit.TrainingRepository.Add(training);
            unit.TrainingRepository.SaveChanges();

            sessionService.UserInfo.TrainingInfo = new TrainingInfo(training);
        }
        public async Task <string> UpdateTrainingSession(int id, TrainingSession trainingSession)
        {
            try
            {
                var res = await _context.TrainingSessions.FirstOrDefaultAsync(m => m.TrainingSessionId == id);

                res.Course              = trainingSession.Course;
                res.TrainingName        = trainingSession.TrainingName;
                res.Details             = trainingSession.Details;
                res.ScheduledTime       = trainingSession.ScheduledTime;
                res.AssignmentDueDate   = trainingSession.AssignmentDueDate;
                res.DeliveryMethod      = trainingSession.DeliveryMethod;
                res.DeliveryLocation    = trainingSession.DeliveryLocation;
                res.AttendanceType      = trainingSession.AttendanceType;
                res.AttendanceStatus    = trainingSession.AttendanceStatus;
                res.AttendanceFeedback  = trainingSession.AttendanceFeedback;
                res.ProofOfCompletion   = trainingSession.ProofOfCompletion;
                res.Attachment          = trainingSession.Attachment;
                res.TrainingCertificate = trainingSession.TrainingCertificate;
                _context.Update(res);
                await _context.SaveChangesAsync();

                return("Updated Record");
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
            public ConversionFactors Calibrate(TrainingSession ts, bool useAlt)
            {
                List <TickDiffPair> calibrationSet = FindCandidates(ts, 100, 1);
                List <TickDiffPair> validationSet  = FindCandidates(ts, 100, 1);

                return(CalibrateIteratively(calibrationSet, validationSet));
            }
Example #13
0
        public void TestLoadSessionBodyRunning()
        {
            // Reading a training session file and checking that the first and last produced datapoints are registered
            // correctly in a TrainingSession.

            FileReader     f         = new FileReader();
            string         session   = f.readFile("C:\\own\\programming\\projects\\TrainingAnalysis\\csharp\\TrainingAnalysis\\TrainingAnalysis\\running_full.tcx");
            string         startTime = TrainingSession.getHeaderInfo(session)["startTime"];
            RunningSession ts        = new RunningSession(startTime);
            bool           success   = ts.loadSessionBody(session);

            Assert.IsTrue(success);
            Assert.AreEqual(2756, ts.mTimeVector.Count);

            // First
            Assert.AreEqual(0, ts.mTimeVector[0]);
            DoubleWithinMargin(58.40579, ts.mPosVector[0].mLatitude, 0.000001);
            DoubleWithinMargin(15.61054333, ts.mPosVector[0].mLongitude, 0.000001);
            DoubleWithinMargin(95.251, ts.mAltVector[0], 0.000001);
            DoubleWithinMargin(3.5, ts.mDistVector[0], 0.000001);
            Assert.AreEqual(124, ts.mHRVector[0]);

            // Last
            Assert.AreEqual(2755, ts.mTimeVector[2755]);
            DoubleWithinMargin(58.40277333, ts.mPosVector[2755].mLatitude, 0.000001);
            DoubleWithinMargin(15.61368, ts.mPosVector[2755].mLongitude, 0.000001);
            DoubleWithinMargin(68.886, ts.mAltVector[2755], 0.000001);
            DoubleWithinMargin(11815.2001953125, ts.mDistVector[2755], 0.000001);
            Assert.AreEqual(166, ts.mHRVector[2755]);
        }
        public ActionResult Create(DateTime date, string expression, string title)
        {
            if (string.IsNullOrWhiteSpace(expression))
            {
                ModelState.AddModelError("expression", "Please type in the exercises.");
            }
            else
            {
                var session = new TrainingSession
                {
                    Date            = date,
                    Key             = string.Empty.RandomString(10),
                    Title           = title.Trim(),
                    IsPublic        = true,
                    IsShared        = true,
                    LoggedExercises = new List <LoggedExercise>()
                };
                SaveSession(session, expression);
                Session["clearLocalStorage"] = true;
                return(RedirectToAction("Shared", new { key = session.Key }));
            }

            ViewBag.SessionTitle = title;
            ViewBag.Date         = date;
            return(View());
        }
        public async Task <IActionResult> PutTrainingSession([FromRoute] int id, [FromBody] TrainingSession trainingSession)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != trainingSession.Id)
            {
                return(BadRequest());
            }

            _context.Entry(trainingSession).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TrainingSessionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #16
0
        public void CreateStatisticTableRow_GoodCase_ReturnsCorrectTableRow()
        {
            var trainingDate = new DateTime(2021, 3, 1);
            var session1     = new TrainingSession
            {
                Simulator = SimulatorName,
                StartDate = trainingDate,
                StartTime = new TimeSpan(0, 0, 0),
                EndDate   = trainingDate,
                EndTime   = new TimeSpan(4, 0, 0)
            };
            var session2 = new TrainingSession
            {
                Simulator = SimulatorName,
                StartDate = trainingDate,
                StartTime = new TimeSpan(4, 00, 0),
                EndDate   = trainingDate,
                EndTime   = new TimeSpan(24, 00, 0)
            };
            var          sessions            = new[] { session1, session2 };
            const string expectedPlannedTime = "24:00";
            var          expectedTableRow    = new StatisticTableRow
            {
                Simulator        = SimulatorName,
                NumberOfSessions = sessions.Length,
                PlannedTime      = expectedPlannedTime,
                AchievedTime     = expectedPlannedTime
            };

            var result = StatisticTableRow.CreateStatisticTableRow(SimulatorName, sessions);

            Assert.IsNotNull(result);
            Assert.AreEqual(expectedTableRow, result);
        }
Example #17
0
        private void IdReceived(int obj)
        {
            TrainingSession t = TrainingSessionService.GetByid(obj);

            // retrieve the good picture in regards to the available seats
            var pictureTraining = "";

            if (t.AvailableSeat == 0)
            {
                pictureTraining = "unavailable.png";
            }
            else if (t.AvailableSeat < 3)
            {
                pictureTraining = "warning.png";
            }

            PictureTrainingSessionViewModel pictureTrainingSessionViewModels = new PictureTrainingSessionViewModel(t, pictureTraining)
            {
                AvailableSeat = t.AvailableSeat, Date = t.Date, Id = t.Id, PictureTraining = pictureTraining
            };


            Items.Add(pictureTrainingSessionViewModels);
            List <PictureTrainingSessionViewModel> trainingSessions = Items.OrderBy(s => s.Date).ToList();

            Items.Clear();

            foreach (PictureTrainingSessionViewModel item in trainingSessions)
            {
                Items.Add(item);
            }
        }
Example #18
0
        public TrainingSession AddTrainingSession(int siteId, int trainingId, int employeeId, DateTime start, int duration, bool delivered)
        {
            // Because we want to have access to the employee in position property on our training session, we need some way to load this from the database.
            // One way would be using lazy loading, so that when we request this property it is loaded from the database.  However, lazy loading is not enabled.
            // So, what we need to do is make use of the EF Context caching.  When we load something from the database, context stores this in a cache.  It is then
            // loaded for any entity that references this loaded data.  In this case, our training session references the EmployeeInPosition that we are loading below
            // As a result, when we save the training session to the database, context will set the EmployeeInPosition property of the training session for us, using
            // the cache
            ISpecification <EmployeeInPosition> specification = new Specification <EmployeeInPosition>(e => e.Id == employeeId);

            specification.FetchStrategy = specification.FetchStrategy.Include(e => e.Employee);
            var employeeInTrainingPosition = _repoEmployeeInTrainingPos.Find(specification);

            var trainingsession = new TrainingSession
            {
                SiteId            = siteId,
                TrainingId        = trainingId,
                EmployeeTrainerId = employeeId,
                Start             = start,
                DurationInMinutes = duration,
                Delivered         = delivered
            };

            _repoTrainingSession.Add(trainingsession);
            return(trainingsession);
        }
Example #19
0
        private async void OpenAddSessionDialogAsync()
        {
            var bodyweight = _trainingSessionService.GetLastUsedBodyweight() ?? 0;

            var trainingSession = new TrainingSession
            {
                Date       = DateTime.Now,
                Bodyweight = bodyweight
            };

            var dialog = _dialogs.For <TrainingSessionDialogViewModel>(DialogsIdentifier);

            dialog.Data.DialogTitle       = "New session";
            dialog.Data.SubmitButtonTitle = "Create";
            dialog.Data.TrainingSession   = TrainingSessionViewModel.FromModel(trainingSession);

            var dialogResult = await dialog.Show();

            if (dialogResult != DialogResult.Ok)
            {
                return;
            }

            trainingSession = dialog.Data.TrainingSession.ToModel();
            TrainingSessions.Add(trainingSession);
            _trainingSessionService.Create(trainingSession);
        }
        private TrainingSession CreateSession(string name, int number)
        {
            var session = new TrainingSession
            {
                Id        = Guid.NewGuid(),
                Name      = name,
                Number    = number,
                Exercises = new List <Exercise>()
            };

            var addedExercises = new HashSet <string>();
            var exercise       = string.Empty;

            for (var i = 1; i <= Random.Next(3, 8); i++)
            {
                while (string.IsNullOrWhiteSpace(exercise) || addedExercises.Contains(exercise))
                {
                    exercise = _database.Exercises.ElementAt(Random.Next(0, _database.Exercises.Count - 1));
                }
                addedExercises.Add(exercise);
                session.Exercises.Add(CreateExercise(exercise, i));
            }

            return(session);
        }
Example #21
0
        public void GetSessionsStatistic_GoodCase_ReturnsCorrectStatistic()
        {
            var trainingDate = new DateTime(2021, 3, 1);
            var session      = new TrainingSession
            {
                Simulator = SimulatorName,
                StartDate = trainingDate,
                StartTime = new TimeSpan(8, 0, 0),
                EndDate   = trainingDate,
                EndTime   = new TimeSpan(12, 0, 0)
            };
            var simulators = new List <string> {
                SimulatorName
            };
            const string expectedSessionTime = "04:00";
            var          expectedStatistic   = new StatisticTableRow
            {
                Simulator        = SimulatorName,
                NumberOfSessions = 1,
                PlannedTime      = expectedSessionTime,
                AchievedTime     = expectedSessionTime
            };
            var docWriterMock    = new Mock <IDocumentsWriter>();
            var documentsService = new DocumentsService(docWriterMock.Object);

            var statistic = documentsService.GetSessionsStatistic(new[] { session }, simulators).ToArray();

            Assert.AreEqual(1, statistic.Length);
            Assert.AreEqual(expectedStatistic, statistic[0]);
        }
 private TreeNode createNode(TrainingSession session)
 {
     TreeNode node = new TreeNode(session.Name);
     node.Tag = session;
     node.Nodes.Add(createNode(session.Database));
     node.Nodes.Add(createNode(session.Network));
     return node;
 }
Example #23
0
        public void DisplayPlayerRemoveDeveloperFromTrainingSession(TrainingSession trainingSession, Developer developer, Company company)
        {
            string text = company.Username + " remove developer " + developer.DeveloperName + " from training session " + trainingSession.Name;

            DisplayPlayerActionInChatBox(text);

            RefreshDisplay(company.CompanyId);
        }
Example #24
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            TrainingSession trainingSession = db.TrainingSessions.Find(id);

            db.TrainingSessions.Remove(trainingSession);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #25
0
 public SessionInPlanViewModel(int trainingSessionId)
 {
     using (var db = new Model1())
     {
         TrainingSession     = db.TrainingSession.First(t => t.SessionId == trainingSessionId);
         ExercisesInSessions = db.ExercisesInSession.Where(e => e.SessionId == TrainingSession.SessionId).ToList();
     }
 }
Example #26
0
        public void DisplayPlayerAssignDeveloperToTrainingSession(TrainingSession trainingSession, Developer developer, Company company)
        {
            string text = company.Username + " set developer " + developer.DeveloperName + " in training session " + trainingSession.Name;

            DisplayPlayerActionInChatBox(text);

            RefreshDisplay(company.CompanyId);
        }
 private decimal?AverageMeasurement(TrainingSession si)
 {
     if (si.MeasurementInfo != null && MeasurmentInfoSelector(si.MeasurementInfo) != null)
     {
         return(MeasurmentInfoSelector(si.MeasurementInfo).Select(x => x.Value).Sum() / MeasurmentInfoSelector(si.MeasurementInfo).Count);
     }
     return(0);
 }
Example #28
0
 public TrainingInfo(TrainingSession training)
 {
     TrainingID  = training.ID;
     DateStarted = training.DateStarted;
     Cards       = training.TrainingCards
                   .Select(card => new TrainingCardInfo(card))
                   .ToList();
 }
        private void buttonRefreshPage_Click(object sender, EventArgs e)
        {
            TrainingSession.GetAllTrainingSessions();

            PopulateDropdownMenu();

            GetSessionInformation();
        }
        // After you modify the training session, do stuff
        private void ChildFormClosing(object sender, FormClosingEventArgs e)
        {
            TrainingSession.GetAllTrainingSessions();

            PopulateDropdownMenu();

            GetSessionInformation();
        }
Example #31
0
        /// <summary>
        /// Register a user to a training Session and publish it to add the training to user's trainings list
        /// </summary>
        /// <param name="obj">The training on which the user would like to register </param>
        private async void SaveRegister(PictureTrainingSessionViewModel obj)
        {
            try
            {
                // If there is not a single seat available for this training session, we show an alert.
                if (obj.AvailableSeat <= 0)
                {
                    await Application.Current.MainPage.DisplayAlert("Aucune place disponible pour cette session.", "", "OK");

                    return;
                }

                bool answer = await Application.Current.MainPage.DisplayAlert("Confirmation d'inscription", "Êtes-vous sûr de vouloir vous inscrire à la session du : " + obj.Date, "Oui", "Non");

                if (answer)
                {
                    int userId = int.Parse(Application.Current.Properties["UserId"].ToString());

                    //Register the user to the training Session in parameter
                    int add = TrainingSessionService.SaveRegister(userId, obj.Id);

                    if (add != 0)
                    {
                        TrainingSession t = new TrainingSession()
                        {
                            Id            = obj.Id,
                            AvailableSeat = obj.AvailableSeat,
                            Date          = obj.Date
                        };
                        //Update the number of available seats
                        t.AvailableSeat -= 1;
                        TrainingSessionService.Update(t);

                        //Remove the session into the available sessions for the user.
                        ObservableCollection <TrainingSession> trainingSessions = new ObservableCollection <TrainingSession>(TrainingSessionService.GetAllByUserId(userId));

                        if (trainingSessions != null)
                        {
                            Items.Remove(obj);
                        }

                        //Event publish to refresh the user's trainings list
                        Event.GetEvent <SentEvent>().Publish(obj.Id);
                        Event.GetEvent <RefreshAvailableTrainingSessionsListEvent>().Publish();

                        await Application.Current.MainPage.DisplayAlert("Validation", "Vous êtes désormais inscrit à la session du : " + obj.Date, "Ok");
                    }
                    else
                    {
                        //Message d'erreur;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
 public void AddToTrainingSessions(TrainingSession trainingSession)
 {
     base.AddObject("TrainingSessions", trainingSession);
 }
 public void Add(TrainingSession session)
 {
     this.trainings.Add(session);
     this.trainings.Save();
 }
 partial void TrainingSessions_Validate(TrainingSession entity, EntitySetValidationResultsBuilder results)
 {
     if (entity.EndDate != null & entity.StartDate != null)
     {
         if (entity.EndDate < entity.StartDate)
         {
             results.AddEntityError("The session cannot end before it has started");
         }
     }
 }
 public static TrainingSession CreateTrainingSession(int ID, global::System.DateTime startDate, global::System.DateTime endDate, int maximumAttendees, int trainingSession_Employee, int trainingSession_Course, byte[] rowVersion)
 {
     TrainingSession trainingSession = new TrainingSession();
     trainingSession.Id = ID;
     trainingSession.StartDate = startDate;
     trainingSession.EndDate = endDate;
     trainingSession.MaximumAttendees = maximumAttendees;
     trainingSession.TrainingSession_Employee = trainingSession_Employee;
     trainingSession.TrainingSession_Course = trainingSession_Course;
     trainingSession.RowVersion = rowVersion;
     return trainingSession;
 }