public ActionResult UpdatePet(Guid id, ExerciseUpdateCreateBaseDto exerciseUpdateDto) { if (!Request.Headers.ContainsKey("token")) { return(Unauthorized()); } var auth = Request.Headers["token"]; var accountModel = _validate.GetAccountByToken(auth); if (accountModel == null) { return(Unauthorized()); } var exerciseModelFromRepo = _repository.GetExerciseById(id, accountModel.Id); if (exerciseModelFromRepo == null) { return(NotFound()); } _mapper.Map(exerciseUpdateDto, exerciseModelFromRepo); _repository.UpdateExercise(exerciseModelFromRepo); _repository.SaveChanges(); return(NoContent()); }
public ActionResult <ExerciseModel> GetExerciseById(string id) { var exercise = _repo.GetExerciseById(id); if (exercise != null) { return(Ok(exercise)); } return(NotFound()); }