Example #1
0
        public async Task <IActionResult> PostAsync([FromBody] CreateDoctorDto doctorDto)
        {
            var doctor        = _mapper.Map <Doctor>(doctorDto);
            var user          = _mapper.Map <User>(doctorDto);
            var createdDoctor = await _doctorService.AddDoctorAsync(doctor, user);

            var readDoctorDto = _mapper.Map <ReadDoctorDto>(createdDoctor);

            return(Created(nameof(GetAsync), new Response <ReadDoctorDto>(readDoctorDto)));
        }
Example #2
0
        public async Task <IActionResult> Add(Doctor _doctor)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Index"));
            }

            var successful = await _doctorService.AddDoctorAsync(_doctor);

            if (!successful)
            {
                return(BadRequest("Could not Add Doctor"));
            }

            return(RedirectToAction("Index"));
        }