public async Task <IActionResult> PutExercise([FromRoute] string id, [FromBody] Exercise exercise)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != exercise.id)
            {
                return(BadRequest());
            }

            _context.Entry(exercise).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ExerciseExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> PutWorkout([FromRoute] string id)
        {
            var workout = await _context.Workouts.SingleOrDefaultAsync(w => w.id == id);

            workout.count++;
            _context.Entry(workout).State = EntityState.Modified;
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!WorkoutExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 3
0
 public ActionResult Edit(Customer customer)
 {
     _context.Entry(customer).State = EntityState.Modified;
     _context.SaveChanges();
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 4
0
 public ActionResult Edit(Training training)
 {
     _context.Entry(training).State = EntityState.Modified;
     _context.SaveChanges();
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 5
0
 public ActionResult Edit(Diet diet)
 {
     _context.Entry(diet).State = EntityState.Modified;
     _context.SaveChanges();
     return(RedirectToAction("Index"));
 }