public IActionResult UpdateTrainer(UpdateTrainerCommand updatedTrainerCommand, int id) { var repo = new TrainerRepository(); var updatedTrainer = new Trainer { Name = updatedTrainerCommand.Name, YearsOfExperience = updatedTrainerCommand.YearsOfExperience, Specialty = updatedTrainerCommand.Specialty, }; var trainer = repo.Update(updatedTrainer, id); return(Ok(trainer)); }
public IActionResult UpdateTrainer(UpdateTrainerCommand updatedTrainerCommand, Guid id) { //mapping/transforming var repo = new TrainerRepository(); var updatedTrainer = new Trainer { Name = updatedTrainerCommand.Name, YearsOfExp = updatedTrainerCommand.YearsOfExp, Specialty = updatedTrainerCommand.Specialty, }; var trainerThatGotUpdated = repo.Update(updatedTrainer, id); return(Ok(trainerThatGotUpdated)); }
public IActionResult UpdateTrainer(UpdateTrainerCommand updatedTrainerCommand, int id) { var updatedTrainer = new Trainer { Name = updatedTrainerCommand.Name, YearsOfExperience = updatedTrainerCommand.YearsOfExperience, Specialty = updatedTrainerCommand.Specialty }; var trainerThatGotUpdated = _repo.Update(updatedTrainer, id); if (trainerThatGotUpdated == null) { return(NotFound("Could not update trainer")); } return(Ok(trainerThatGotUpdated)); }
public IActionResult UpdateTrainer(UpdateTrainerCommand updatedTrainerCommand, int id) { var repo = new TrainerRepository(); var updatedTrainer = new Trainer { Name = updatedTrainerCommand.Name, YearOfExperience = updatedTrainerCommand.YearOfExperience, Specialty = updatedTrainerCommand.Specialty, }; var updatedRepoTrainer = repo.Update(updatedTrainer, id); if (updatedRepoTrainer == null) { return(NotFound("Could not update trainer")); } return(Ok(updatedRepoTrainer)); }
public async Task <IActionResult> Update([FromBody] UpdateTrainerCommand command) { await _mediator.Send(command); return(StatusCode(StatusCodes.Status204NoContent)); }