public async Task <IActionResult> AthletesList([FromForm] AthletesViewModel athletesViewModel) { var users = _dbContext.User.Where(s => s.Name == athletesViewModel.AName); UserTestMapping userTestMapping = new UserTestMapping(); TestDetails testDetails = new TestDetails(); TestTypeMapping typeMapping = new TestTypeMapping(); typeMapping.TestId = testDetails.ID; _dbContext.UserTestMapping.Add(userTestMapping); await _dbContext.SaveChangesAsync(); return(RedirectToAction("TestAthleteDetails", new { id = testId })); }
public async Task <IActionResult> NewAthlete([FromForm] AthletesViewModel athletesViewModel) { UserTestMapping userTest = new UserTestMapping(); //var NewA = _dbContext.User.Where(s => s.ID == athletesViewModel.UserId).Select(s => s.Name); var NewA = _dbContext.User.Where(s => s.Name == athletesViewModel.AName).Select(s => s.ID).First(); userTest.UserId = NewA; if (athletesViewModel.CTDistance != null) { userTest.FitnessRating = CalculateFitness(athletesViewModel.CTDistance); } userTest.TestId = testId; userTest.CTDistance = athletesViewModel.CTDistance; //userTest.FitnessRating = CalculateFitness(athletesViewModel.CTDistance); userTest.STTime = athletesViewModel.STTime; _dbContext.UserTestMapping.Add(userTest); await _dbContext.SaveChangesAsync(); return(RedirectToAction("TestAthleteDetails", new { id = testId })); }