コード例 #1
0
        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));
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 public void Update(AthletePerformance athletePerformance)
 {
     _context.AthletePerformances.Update(athletePerformance);
     _context.SaveChanges();
 }
コード例 #4
0
 public void Add(AthletePerformance athletePerformance)
 {
     _context.AthletePerformances.Add(athletePerformance);
     _context.SaveChanges();
 }
コード例 #5
0
 public IActionResult Update(AthletePerformance athletePerformance)
 {
     _athletePerformanceRepository.Update(athletePerformance);
     return(RedirectToAction("Index"));
 }