Exemple #1
0
        public IActionResult CreateDoctor([FromBody] DoctorCreateDto doctor)
        {
            if (doctor == null)
            {
                return(BadRequest(ModelState));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var doctorsObj = _mapper.Map <Doctor>(doctor);

            if (_doctor.CRMEndExists(doctorsObj.CRM + doctorsObj.CRMUF))
            {
                ModelState.AddModelError("", "This CRM already Exist");
                return(StatusCode(404, ModelState));
            }

            doctorsObj.CRMEnd = doctorsObj.CRM + doctorsObj.CRMUF;

            if (!_doctor.CreateDoctor(doctorsObj))
            {
                ModelState.AddModelError("", $"Something went wrong when you trying to save {doctor.Name}");
                return(StatusCode(500, ModelState));
            }

            return(CreatedAtRoute("GetDoctor", new { version = HttpContext.GetRequestedApiVersion().ToString(), id = doctorsObj.Id }, doctorsObj));
        }
 protected override void OnInitialized()
 {
     people          = PersonService.GetPersonIdAndNames();
     specializations = SpecializationService.GetSpecializationIdAndNames();
     createDto       = new DoctorCreateDto(DoctorService, PersonService, SpecializationService, PasswordEncryptionUtil);
     editContext     = new EditContext(createDto);
     base.OnInitialized();
 }
Exemple #3
0
        public ActionResult <DoctorCreateDto> CreateDoctor(DoctorCreateDto doctorCreate)
        {
            var DoctorModel = _mapper.Map <DoctorDetails>(doctorCreate);

            _doctorsRepo.CreateDoctor(DoctorModel);
            _doctorsRepo.SaveChanges();

            var doctorReadDto = _mapper.Map <DoctorReadDto>(DoctorModel);

            return(CreatedAtRoute(nameof(GetDoctorById), new { Id = doctorReadDto.UserId }, doctorReadDto));
        }
Exemple #4
0
        public async Task <ActionResult> Create([FromForm] DoctorCreateDto doctorCreateDto)
        {
            var mapperDoctor = _mapper.Map <Doctor>(doctorCreateDto);

            string folderName = Path.Combine("images", "doctors");
            string fileName   = await doctorCreateDto.Photo.SaveImg(_env.WebRootPath, folderName);

            mapperDoctor.PhotoUrl = fileName;
            await _doctorRepository.CreateDoctorAsync(mapperDoctor);

            return(Ok(mapperDoctor));
        }
 public static Entities.DoctorAggregate.Doctor Create(DoctorCreateDto dto)
 {
     return(new (
                dto.Alias,
                dto.FirstName,
                dto.LastName,
                dto.MiddleName,
                dto.Titles,
                dto.WorkExperience,
                dto.Description,
                dto.Photo
                ));
 }
 public DoctorCreateDto Create(DoctorCreateDto doctor)
 {
     if (doctor != null)
     {
         var doc = new Doctor();
         doc.Id    = doctor.Id;
         doc.Name  = doctor.Name;
         doc.Phone = doctor.Phone;
         _doctorRepository.Create(doc);
         _unitOfWork.Complete();
     }
     return(doctor);
 }
 public Task <int> CreateAsync(DoctorCreateDto createDto) => _repository.CreateAsync(_mapper.Map <Doctor>(createDto));