Beispiel #1
0
 public ProfessorsControllerTests()
 {
     updateProfessorModel = new UpdateProfessorModel();
     mockRepo             = new Mock <IProfessorService>();
     controller           = new ProfessorController(mockRepo.Object);
     professorModel       = Mapper.Map <UpdateProfessorModel, Professor>(updateProfessorModel);
 }
Beispiel #2
0
        public async Task <IActionResult> UpdateProfessor([FromBody] UpdateProfessorModel createProfessorModel, Guid id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var professor = await professorService.GetCourseByProfId(id);

            if (professor == null)
            {
                return(NotFound());
            }

            var professorModel = Mapper.Map <UpdateProfessorModel, Professor>(createProfessorModel);

            await professorService.UpdateAsync(id, professorModel);

            return(NoContent());
        }