Beispiel #1
0
        public async Task <IActionResult> PostAsync(CreateDoctorRequest request, CancellationToken cancellationToken)
        {
            _logger.LogInformation("Patients/Post was requested.");
            var response = await unitOfWork.Doctors.CreateAsync(_mapper.Map <DoctorDTO>(request));

            unitOfWork.Save();
            return(Ok(_mapper.Map <DoctorResponce>(response)));
        }
Beispiel #2
0
 public void CreateDoctor(CreateDoctorRequest request)
 {
     _context.Doctors.Add(new Doctor {
         IdDoctor  = request.IdDoctor,
         FirstName = request.FirstName,
         LastName  = request.LastName,
         Email     = request.Email
     });
     _context.SaveChanges();
 }
Beispiel #3
0
        public IActionResult CreateDoctor(CreateDoctorRequest request)
        {
            var res = new Doctor
            {
                FirstName = request.FirstName,
                LastName  = request.LastName,
                Email     = request.Email
            };

            _context.Doctors.Add(res);
            _context.SaveChanges();
            return(Ok(res));
        }
Beispiel #4
0
        public void UpdateDoctor(CreateDoctorRequest request)
        {
            var doctor = _context.Doctors.SingleOrDefault(d => d.IdDoctor == request.IdDoctor);

            if (doctor == null)
            {
                throw new Exception("Nie ma takiego doktora");
            }
            doctor.IdDoctor  = request.IdDoctor;
            doctor.FirstName = request.FirstName;
            doctor.LastName  = request.LastName;
            doctor.Email     = request.Email;
            _context.SaveChanges();
        }
Beispiel #5
0
        public IActionResult CreateDoctor(CreateDoctorRequest request)
        {
            var doctor = new Doctor
            {
                FirstName     = request.FirstName,
                LastName      = request.LastName,
                Email         = request.Email,
                Prescriptions = request.Prescriptions
            };

            _context.Attach(doctor);
            _context.Doctor.Add(doctor);
            _context.SaveChanges();

            return(Ok(doctor));
        }
        private async Task SaveClick()
        {
            if (ToSave.DoctorId == 0)
            {
                var toCreate = new CreateDoctorRequest()
                {
                    Name = ToSave.Name,
                };
                await DoctorService.CreateAsync(toCreate);
            }
            else
            {
                var toUpdate = new UpdateDoctorRequest()
                {
                    DoctorId = ToSave.DoctorId,
                    Name     = ToSave.Name,
                };
                await DoctorService.EditAsync(toUpdate);
            }

            CancelClick();
            await ReloadData();
        }
 public IActionResult UpdateDoctor(CreateDoctorRequest request)
 {
     _service.UpdateDoctor(request);
     return(Ok());
 }
 public IActionResult CreateDoctor(CreateDoctorRequest request)
 {
     _service.CreateDoctor(request);
     return(Created(nameof(request), request));
 }
Beispiel #9
0
 public async Task <DoctorDto> CreateAsync(CreateDoctorRequest doctor)
 {
     return((await _httpService.HttpPostAsync <CreateDoctorResponse>("doctors", doctor)).Doctor);
 }