public ActionResult <Training> CreateTraining([FromBody] TrainingDTO trainingDTO, string email) { Gymnast gymnast = _gymnasts.GetByEmail(email); Category category = _categories.GetbyId(trainingDTO.CategoryId); if (gymnast == null) { return(NotFound("Geen gymnast met dit ID.")); } if (category == null && trainingDTO.Category != null) { category = new Category(trainingDTO.Category, ""); // tijdelijke geen beschrijving _categories.SaveChanges(); } if (category == null && trainingDTO.Category == null) { return(NotFound("Geen category met dit ID")); } try { Training training = new Training(category, trainingDTO.Date, trainingDTO.FeelingBeforeTraining, trainingDTO.FeelingAfterTraining); gymnast.AddTraining(training); _gymnasts.SaveChanges(); return(CreatedAtAction(nameof(GetTraining), new { trainingId = training.Id }, training)); } catch (Exception e) { return(StatusCode(StatusCodes.Status500InternalServerError, e.Message)); } }
public void DisplayGymnast_Click(object sender, EventArgs e) { // gets the name of the gymnast we're looking for and searches for them out of the list of all the gymnasts created string name = chooseGymnast.Text; int k = 0; for (k = 0; k <= i; k++) { gymnast = gymnastList[k]; if (gymnast.name == name) { break; } } // displays the gymnast's information athleteGym.Text = gymnast.gym; athleteName.Text = gymnast.name; floorScore.Text = gymnast.fxscore.ToString(); pommelScore.Text = gymnast.phscore.ToString(); ringsScore.Text = gymnast.srscore.ToString(); vaultScore.Text = gymnast.vtscore.ToString(); pbarScore.Text = gymnast.pbscore.ToString(); hbarScore.Text = gymnast.hbscore.ToString(); aaScore.Text = gymnast.aascore.ToString(); }
public GymnastCoach(Gymnast g, Coach c) { Gymnast = g; GymnastId = g.Id; Coach = c; CoachId = c.Id; }
public void AddGymnast(Gymnast newGymnast, int idCompetition) { int idNewGymnast; idNewGymnast = _repository.AddGymnast(newGymnast); _repository.AddCompetitor(idCompetition, idNewGymnast); }
public async Task <IActionResult> PutGymnast([FromBody] Gymnast updatedGymnast) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var gymnastInDb = await _context.Gymnasts.FirstOrDefaultAsync(g => g.Id == updatedGymnast.Id); if (gymnastInDb == null) { throw new KeyNotFoundException(); } // If training level has changed, check to see if new clothing is needed // if (updatedGymnast.Level != gymnastInDb.Level) _clothingUpdateService.SetGymnastClothingNeedsFlags(gymnastInDb, updatedGymnast); // If measurements have changed, check to see if new clothing is needed _context.Entry(gymnastInDb).State = EntityState.Modified; _context.Entry(gymnastInDb).CurrentValues.SetValues(updatedGymnast); await _context.SaveChangesAsync(); return(Ok()); } catch (Exception ex) { if (ex is KeyNotFoundException) { return(NotFound()); } return(StatusCode(StatusCodes.Status500InternalServerError)); } }
private static bool CheckIfLeoNeededBecauseOfSizeChange(Gymnast gymnast, Gymnast updatedGymnast) { // need to create this method // var updatedLeoSize = GetLeoSizeFromMeasurements(updatedGymnast.ChestMeasurement, updatedGymnast.WaistMeasurement, updatedGymnast.HipsMeasurement); // var updatedTorsoSize = GetTorsoSizeFromMeasurements(updatedLeoSize, updatedGymnast.TorsoMeasurement); return(true); }
// adding an event with a score sheet public Routine(string apparatus, Gymnast name, Sheet result, float score) { this._competitor = name; this._apparatus = apparatus; this._result = result; this._score = score; }
public ViewModel() { _repository = new Repository(); _gymnasts = new List <Gymnast>(); _ratings = new List <Rating>(); _newGymnastInfo = new Gymnast(); _competitors = new List <Competitor>(); _competitions = _repository.GetCompetitions(); Disciplins = new ObservableCollection <string> { "Choose a discipline", DisciplineIs.FloorExercise.ToString(), DisciplineIs.PommelHorse.ToString(), DisciplineIs.StillRings.ToString(), DisciplineIs.Vault.ToString(), DisciplineIs.ParallelBars.ToString(), DisciplineIs.HighBar.ToString(), "Total" }; AddCommand = new RelayComand(Add); RemoveCommand = new RelayComand(Remove); SaveRatingsCommand = new RelayComand(SaveRatings); UpdateViewRatingsCommand = new RelayComand(UpdateViewRatings); GetCompetitorsCommand = new RelayComand(GetCompetitors); ShowNewWindowCommand = new RelayComand(ShowNewWindow); }
public void SetGymnastClothingNeedsFlags(Gymnast gymnast, Gymnast updatedGymnast) { if (gymnast.Level != updatedGymnast.Level) { gymnast.NeedsLeo = CheckIfLeoNeeded(gymnast, updatedGymnast); gymnast.NeedsJacket = ChekIfJacketNeeded(gymnast, updatedGymnast); } }
public void Gymnast_ValidContructor_CreatesObject() { Gymnast testGymnast = new Gymnast("Florian", "Landuyt", new DateTime(1996, 05, 10), "*****@*****.**"); Assert.Equal("Florian", testGymnast.Firstname); Assert.Equal("Landuyt", testGymnast.Lastname); Assert.Equal("*****@*****.**", testGymnast.Email); }
public static void Main() { Boxer boxer = new Boxer(20, 10); boxer.EnterEvent(); Gymnast gymnast = new Gymnast(8, 9); gymnast.EnterEvent(); }
// adds a gymnast to the event one routine at a time public void AddGymnast(Gymnast gymnast) { this._floor.AddRoutine(gymnast.fxroutine); this._pommel.AddRoutine(gymnast.phroutine); this._rings.AddRoutine(gymnast.srroutine); this._vault.AddRoutine(gymnast.vtroutine); this._pbars.AddRoutine(gymnast.pbroutine); this._hbar.AddRoutine(gymnast.hbroutine); this._aaround.AddRoutine(gymnast.aaroutine); }
public static bool ChekIfJacketNeeded(Gymnast gymnast, Gymnast updatedGymnast) { if (gymnast.Level >= LevelsEnum.Level3 && updatedGymnast.Level >= LevelsEnum.Level3) { var updatedJacketSize = GetJacketSizeFromMeasurements(updatedGymnast.ChestMeasurement, updatedGymnast.WaistMeasurement); var updatedTorsoSize = GetTorsoSizeFromMeasurements(updatedJacketSize, updatedGymnast.TorsoMeasurement); return(updatedJacketSize != gymnast.LeoAndJacketSize || updatedTorsoSize != gymnast.TorsoSize); } return(false); }
public void AddCompetitor(int id, Gymnast newGymnastInf) { if (newGymnastInf.Country == null || newGymnastInf.FirstName == null || newGymnastInf.LastName == null) { throw new ArgumentNullException("Please specify mandatory fields(FirstName, LastName, Country, idCompetition!"); } else { _server.AddGymnast(newGymnastInf, id); } }
public static bool CheckIfLeoNeeded(Gymnast gymnast, Gymnast updatedGymnast) { var needsLeoBecauseOfLevelChange = CheckIfLeoNeededBecauseOfLevelChange(gymnast.Level, updatedGymnast.Level); if (needsLeoBecauseOfLevelChange) { return(true); } var needsLeoBecauseOfSizeChange = CheckIfLeoNeededBecauseOfSizeChange(gymnast, updatedGymnast); return(false); }
public DummyDbContext() { #region init Gymnasts G1 = new Gymnast("Florian", "Landuyt", new DateTime(1996, 05, 10), "*****@*****.**"); G2 = new Gymnast("Jonathan", "Vrolix", new DateTime(1996, 11, 09), "*****@*****.**"); Gymnasts = new[] { G1, G2 }; NewGymnast = new Gymnast("Alex", "Pieters", new DateTime(1996, 12, 20), "*****@*****.**"); #endregion #region init Categories C1 = new Category("General", ""); C2 = new Category("Legpower", ""); C3 = new Category("Corestability", ""); Categories = new[] { C1, C2, C3 }; #endregion #region init Trainings int trainingId = 1; T1 = new Training(C1, new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day), 5, 7) { Id = trainingId }; T2 = new Training(C3, new DateTime(DateTime.Now.AddDays(3).Year, DateTime.Now.AddDays(3).Month, DateTime.Now.AddDays(3).Day), 4, 8) { Id = trainingId++ }; T3 = new Training(C2, new DateTime(DateTime.Now.AddDays(4).Year, DateTime.Now.AddDays(4).Month, DateTime.Now.AddDays(4).Day)) { Id = trainingId + 2 }; Trainings = new[] { T1, T2, T3 }; NewTraining = new Training(C2, new DateTime(DateTime.Now.AddDays(5).Year, DateTime.Now.AddDays(5).Month, DateTime.Now.AddDays(5).Day), 9, 9) { Id = trainingId + 3 }; #endregion }
public async Task <IActionResult> Create([Bind("GymnastId,FirstName,LastName,DateOfBirth,UserId")] Gymnast gymnast) { ModelState.Remove("User"); ModelState.Remove("UserId"); if (ModelState.IsValid) { // Get the current user var user = await GetCurrentUserAsync(); gymnast.User = user; _context.Add(gymnast); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } //ViewData["UserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", gymnast.UserId); return(View(gymnast)); }
private void Add() { if (_newGymnastInfo.LastName == null || _newGymnastInfo.FirstName == null) { MessageBox.Show("Information about the gymnast has not been written. Please fill in!"); } else { if (_selectedCompetition == null) { MessageBox.Show("You did not create new competitions or did not choose from existing ones. Please choose or create new competitions!"); } else { int idNewGymnast = _repository.AddGymnast(_newGymnastInfo); _repository.AddCompetitor(_selectedCompetition.Id, idNewGymnast); NewGymnastInfo = new Gymnast(); UpdateViewRatings(); } } }
public async Task <IActionResult> AddGymnast([FromBody] Gymnast gymnast) { try { if (!ModelState.IsValid) { throw new InvalidDataException(); } _context.Gymnasts.Add(gymnast); await _context.SaveChangesAsync(); return(CreatedAtAction("GetGymnast", new { id = gymnast.Id }, gymnast)); } catch (Exception ex) { if (ex is InvalidDataException) { return(BadRequest()); } return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public async Task <IActionResult> Edit(int id, [Bind("GymnastId,FirstName,LastName,DateOfBirth,UserId")] Gymnast gymnast) { if (id != gymnast.GymnastId) { return(NotFound()); } ModelState.Remove("User"); ModelState.Remove("UserId"); if (ModelState.IsValid) { try { // Get the current user var user = await GetCurrentUserAsync(); gymnast.User = user; _context.Update(gymnast); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GymnastExists(gymnast.GymnastId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } //ViewData["UserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", gymnast.UserId); return(View(gymnast)); }
public async Task InitializeData() { _dbContext.Database.EnsureDeleted(); if (_dbContext.Database.EnsureCreated()) { #region Users // ----------- Creating the coaches and gymnasts --------------- var password = "******"; //Coach stefan = new Coach("Stefan", "Deckx", new DateTime(1978, 02, 10), "*****@*****.**"); //Coach koen = new Coach("Koen", "Van Damme", new DateTime(1986, 03, 10), "*****@*****.**"); //Gymnast florian = new Gymnast("Florian", "Landuyt", new DateTime(1996, 05, 10), "*****@*****.**"); //Gymnast jonathan = new Gymnast("Jonathan", "Vrolix", new DateTime(1996, 11, 09), "*****@*****.**"); Gymnast gymnast = new Gymnast("sport", "gymnast", new DateTime(1996, 05, 10), "*****@*****.**"); CreateUser(gymnast, password); //CreateUser(jonathan, password); //CreateUser(koen, password); //CreateUser(stefan, password); // ---------- Adding gymnasts to their coaches ----------------- // stefan.AddGymnast(florian); // stefan.AddGymnast(jonathan); // koen.AddGymnast(florian); // // ---------- Adding users to the database --------------------- await _userManager.AddPasswordAsync(gymnast, password); // //await _userManager.AddPasswordAsync(jonathan, password); // //await _userManager.AddPasswordAsync(koen, password); // //await _userManager.AddPasswordAsync(stefan, password); // // ---------- Creating the users ------------------------------- // //await CreateUser(stefan, password); // //await CreateUser(koen, password); // //await CreateUser(jonathan, password); //await CreateUser(florian, password); #endregion // #region Categories // Category general = new Category("General", ""); // Category legpower = new Category("Legpower", ""); // Category schoulderPower = new Category("Shoulders", ""); // Category corestability = new Category("Corestability", ""); // Category backpower = new Category("Backpower", ""); // _dbContext.Categories.Add(general); // _dbContext.Categories.Add(corestability); // _dbContext.Categories.Add(schoulderPower); // _dbContext.Categories.Add(legpower); // _dbContext.Categories.Add(backpower); // #endregion // #region Trainings // Training t1 = new Training(general, new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day), 5,7); // Training t2 = new Training(corestability, new DateTime(DateTime.Now.AddDays(3).Year, DateTime.Now.AddDays(3).Month, DateTime.Now.AddDays(3).Day),4,8); // Training t3 = new Training(legpower, new DateTime(DateTime.Now.AddDays(4).Year, DateTime.Now.AddDays(4).Month, DateTime.Now.AddDays(4).Day)); // Training t4 = new Training(backpower, new DateTime(DateTime.Now.AddDays(5).Year, DateTime.Now.AddDays(5).Month, DateTime.Now.AddDays(5).Day), 9,9); // Training t5 = new Training(backpower, new DateTime(DateTime.Now.AddDays(5).Year, DateTime.Now.AddDays(5).Month, DateTime.Now.AddDays(5).Day), 9, 9); // _dbContext.Trainings.Add(t1); // _dbContext.Trainings.Add(t2); // _dbContext.Trainings.Add(t3); // _dbContext.Trainings.Add(t4); // _dbContext.Trainings.Add(t5); // Exercise e1 = new Exercise("Squat", "www.image.be"); // Exercise e2 = new Exercise("Biceps", "www.image.be"); // Exercise e3 = new Exercise("Triceps", "www.image.be"); // Exercise e4 = new Exercise("Flies", "www.image.be"); // Exercise e5 = new Exercise("Kettle bell swing", "www.image.be"); // Exercise e6 = new Exercise("Quadriceps", "www.image.be"); // Exercise e7 = new Exercise("Polsen op en neer", "www.image.be"); // Exercise e8 = new Exercise("Xco met knieen op bal", "www.image.be"); // Exercise e9 = new Exercise("Flex bars", "www.image.be"); // Exercise e10 = new Exercise("Gyrospinn", "www.image.be"); // ExerciseEvaluation ee1 = new ExerciseEvaluation("Gaat beter dan vorige week", 8, 12.0, 20, 3, e1); // //ExerciseEvaluation ee2 = new ExerciseEvaluation("Pijn aan linkerschouder", 4, 0, 20, 3, e2); // ExerciseEvaluation ee3 = new ExerciseEvaluation("Kan volgende week hoger gewicht", 9, 12.0, 20, 3, e3); // ExerciseEvaluation ee4 = new ExerciseEvaluation("toch weer iets meer pijn, iets rustiger doen de volgende keer", 5, 12.0, 20, 3, e1); // t1.AddExerciseEvaluationToTraining(ee1); //// t1.AddExerciseEvaluationToTraining(ee2); // t1.AddExerciseEvaluationToTraining(ee3); // t3.AddExerciseEvaluationToTraining(ee4); // t1.AddExerciseToTraining(e1); // t1.AddExerciseToTraining(e2); // t1.AddExerciseToTraining(e3); // t2.AddExerciseToTraining(e2); // florian.AddTraining(t1); // florian.AddTraining(t2); // florian.AddTraining(t3); // florian.AddTraining(t4); // jonathan.AddTraining(t5); _dbContext.Gymnasts.Add(gymnast); // _dbContext.Gymnasts.Add(jonathan); // _dbContext.Coaches.Add(stefan); // _dbContext.Coaches.Add(koen); // _dbContext.Excercises.Add(e4); // _dbContext.Excercises.Add(e5); // _dbContext.Excercises.Add(e6); // _dbContext.Excercises.Add(e7); // _dbContext.Excercises.Add(e8); // _dbContext.Excercises.Add(e9); // _dbContext.Excercises.Add(e10); // #endregion _dbContext.SaveChanges(); } }
public void AddGymnast(Gymnast competitor) { gymnasts.Add(competitor); }
public void AddGymnast_Click(object sender, EventArgs e) { // adding a gymnast to the list of gymnasts string name = athleteName.Text; string gym = athleteGym.Text; gymnast = new Gymnast(name, gym); athleteName.Text = ""; athleteGym.Text = ""; float fx; float ph; float sr; float vt; float pb; float hb; // these following lines read in the scores from the text boxes if (floorScore.Text == "") { fx = 0; } else { fx = float.Parse(floorScore.Text); } if (pommelScore.Text == "") { ph = 0; } else { ph = float.Parse(pommelScore.Text); } if (ringsScore.Text == "") { sr = 0; } else { sr = float.Parse(ringsScore.Text); } if (vaultScore.Text == "") { vt = 0; } else { vt = float.Parse(vaultScore.Text); } if (pbarScore.Text == "") { pb = 0; } else { pb = float.Parse(pbarScore.Text); } if (hbarScore.Text == "") { hb = 0; } else { hb = float.Parse(hbarScore.Text); } // adding the scores to the new gymnast class gymnast.AddScore(fx, "FX"); gymnast.AddScore(ph, "PH"); gymnast.AddScore(sr, "SR"); gymnast.AddScore(vt, "VT"); gymnast.AddScore(pb, "PB"); gymnast.AddScore(hb, "HB"); if (aaScore.Text == "") { gymnast.calAA(); } else { gymnast.AddScore(float.Parse(aaScore.Text), "AA"); } // some clean up to allow another gymnast to be created shortly floorScore.Text = ""; pommelScore.Text = ""; ringsScore.Text = ""; vaultScore.Text = ""; pbarScore.Text = ""; hbarScore.Text = ""; aaScore.Text = ""; chooseGymnast.Items.Add(name); gymnastList[i] = gymnast; i++; }
private void ToMeet_Click(object sender, EventArgs e) { // finds the correct gymnast and meet string name = chooseGymnast.Text; int k = 0; if (name == "") { return; } for (k = 0; k <= i; k++) { gymnast = gymnastList[k]; if (gymnast.name == name) { break; } } string competition = chooseMeet.Text; if (competition == "") { return; } for (k = 0; k < v; k++) { meet = meetList[k]; if (meet.meetName == competition) { break; } } // adds the event and gymnast to the meet // only adds the event if there is not one already created if (meet._floor == null) { meet.AddEvent("FX"); } if (meet._pommel == null) { meet.AddEvent("PH"); } if (meet._rings == null) { meet.AddEvent("SR"); } if (meet._vault == null) { meet.AddEvent("VT"); } if (meet._pbars == null) { meet.AddEvent("PB"); } if (meet._hbar == null) { meet.AddEvent("HB"); } if (meet._aaround == null) { meet.AddEvent("AA"); } meet.AddGymnast(gymnast); }
public void Remove(Gymnast obj) { _gymnasts.Remove(obj); }
public void Add(Gymnast obj) { _gymnasts.Add(obj); }