public async Task <IActionResult> PutCooperTestDetail([FromRoute] int id, [FromBody] CooperTestDetail cooperTestDetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != cooperTestDetail.Id) { return(BadRequest()); } _context.Entry(cooperTestDetail).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CooperTestDetailExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
// GET: Tests public async Task <IActionResult> Index() { foreach (var db in _context.Test) { db.NumOfParticipants = getNumOfParticipants(db.TestId); } await _context.SaveChangesAsync(); var Tests = from t in _context.Test orderby t.Date descending select t; return(View(await Tests.ToListAsync())); }
public async Task <IActionResult> Create([Bind("AthleteName,Distance")] TestDetails testDetails, int id) { testDetails.TestId = id; if (ModelState.IsValid) { testDetails.MyProperty = this.checkFitness(testDetails.Distance); _context.Add(testDetails); await _context.SaveChangesAsync(); return(RedirectToAction("Index", "TestDetails", new { id = testDetails.TestId })); } return(View(testDetails)); }