Beispiel #1
0
        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));
        }
Beispiel #3
0
        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));
        }
Beispiel #5
0
        public async Task <IActionResult> Update([FromBody] UpdateTrainerCommand command)
        {
            await _mediator.Send(command);

            return(StatusCode(StatusCodes.Status204NoContent));
        }