Beispiel #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));
        }
Beispiel #2
0
        public ActionResult Create(Doctor doctor, IEnumerable <int> items)
        {
            if (_doctorRepository.IsDoctor(doctor))
            {
                ModelState.AddModelError(nameof(doctor.FullName), "Доктор с таким именем уже существует");
            }
            if (items.Count() == 0)
            {
                ModelState.AddModelError(nameof(doctor.Speciality), "Укажите специальность");
            }
            if (ModelState.IsValid)
            {
                _doctorRepository.CreateDoctor(doctor, items);

                return(RedirectToAction("Index"));
            }

            var viewModel = new DoctorViewModel
            {
                Doctor      = doctor,
                Specilities = new SelectList(_specialityRepository.GetSpecialities(), "SpecialityId", "Name")
            };

            return(View(viewModel));
        }
Beispiel #3
0
        public DoctorDTO CreateDoctor([FromBody] DoctorDTO doctor)
        {
            Doctor doctorEntity = _mapper.Map <Doctor>(doctor);

            _repository.CreateDoctor(doctorEntity);
            _repository.Save();
            DoctorDTO newDoctor = _mapper.Map <DoctorDTO>(doctorEntity);

            return(newDoctor);
        }
            public async Task <Response> Handle(CreateDoctorCommand request, CancellationToken cancellationToken)
            {
                var doc = await _doctorRepository.CreateDoctor(new Doctor()
                {
                    FirstName = request.FirstName, LastName = request.LastName, HudumaNumber = request.HudumaNumber
                });

                _logger.LogInformation($"Doctor was successfully created.");

                response.error   = false;
                response.data    = doc;
                response.message = "doctor was successfully registered.";

                return(response);
            }
        public DoctorViewModel CreateDoctor(DoctorBindingModel doctorBindingModel)
        {
            var doctor = _doctorRepository.CreateDoctor(new Doctor
            {
                FirstName   = doctorBindingModel.FirstName,
                LastName    = doctorBindingModel.LastName,
                Description = doctorBindingModel.Description,
                Price       = doctorBindingModel.Price,
                IsActive    = true
            });

            return(new DoctorViewModel
            {
                FirstName = doctor.FirstName,
                LastName = doctor.LastName,
                Description = doctor.Description,
                Price = doctor.Price
            });
        }
Beispiel #6
0
 public async Task <Doctor> CreateDoctor(Doctor doctor)
 {
     return(await doctorRepository.CreateDoctor(doctor));
 }
 public IActionResult CreateDoctor(Doctor doctor)
 {
     _docrepo.CreateDoctor(doctor);
     return(RedirectToAction("ListDoctors"));
 }