public async Task <IActionResult> register([FromBody] SaveInstructorResource instructorResource) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Instructor instructor = mapper.Map <SaveInstructorResource, Instructor>(instructorResource); instructorRepository.Add(instructor); await unitOfWork.CompleteAsync(); instructor = await instructorRepository.GetOne(instructor.Id); var response = mapper.Map <Instructor, SaveInstructorResource>(instructor); return(Ok(response)); }
public async Task <IActionResult> activateInstructor(int id) { Instructor instructor = await instructorRepository.GetOne(id); if (instructor == null) { return(NotFound()); } instructor.IsActivated = !instructor.IsActivated; await unitOfWork.CompleteAsync(); instructor = await instructorRepository.GetOne(id); var response = mapper.Map <Instructor, InstructorResource>(instructor); return(Ok(response)); }