示例#1
0
        public async Task <ActionResult> Create(DoctorCreateModel doctorCreateModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(doctorCreateModel));
            }
            DoctorDto doctorDto = new DoctorDto
            {
                Username       = doctorCreateModel.Username,
                Password       = doctorCreateModel.Password,
                Specialization = doctorCreateModel.Specialization,
                Name           = doctorCreateModel.Name,
                Surname        = doctorCreateModel.Surname
            };

            if (await PatientFacade.GetPatientByUsernameAsync(doctorCreateModel.Username) != null ||
                await DoctorFacade.GetDoctorByUsernameAsync(doctorCreateModel.Username) != null)
            {
                ModelState.AddModelError("Username", "Account with that username already exists");
                return(View(doctorCreateModel));
            }
            await DoctorFacade.RegisterDoctor(doctorDto);

            return(RedirectToAction("Login", "Account"));
        }
示例#2
0
        public async Task <IActionResult> CreateDoctor([FromBody] DoctorCreateModel model)
        {
            var result = await _doctorService.CreateDoctor(_mapper.Map <DoctorDTO>(model));

            return(CreatedAtAction(nameof(GetDoctorById), new
            {
                id = result.Id
            }, result));
        }