public IActionResult Put(string userId, [FromBody] AthletePerformance performance) { // var updated = this.repository.SavePerformance(performance); // return new ObjectResult(updated); this.repository.SavePerformance(performance); var namedPerformance = this.repository.GetNamedPerformance(userId); return(new ObjectResult(namedPerformance)); }
public AthletePerformance SavePerformance(AthletePerformance performance) { var existingPerformance = this.GetPerformance(performance.UserId); if (existingPerformance == null) { this.context.AthletePerformances.Add(performance); } else { existingPerformance.BikeTarget = performance.BikeTarget; existingPerformance.RowTarget = performance.RowTarget; existingPerformance.RunTarget = performance.RunTarget; this.context.AthletePerformances.Update(existingPerformance); } this.context.SaveChanges(); return(existingPerformance ?? performance); }
public void Update(AthletePerformance athletePerformance) { _context.AthletePerformances.Update(athletePerformance); _context.SaveChanges(); }
public void Add(AthletePerformance athletePerformance) { _context.AthletePerformances.Add(athletePerformance); _context.SaveChanges(); }
public IActionResult Update(AthletePerformance athletePerformance) { _athletePerformanceRepository.Update(athletePerformance); return(RedirectToAction("Index")); }