コード例 #1
0
        public void UpdateDoctor(UpdateDoctorRequest request, int id)
        {
            var doctor = new Doctor();

            doctor.IdDoctor = id;
            _context.Attach(doctor);
            var firstName = request.FirstName;
            var lastName  = request.LastName;
            var email     = request.Email;
            var entry     = _context.Entry(doctor);

            if (firstName != null)
            {
                doctor.FirstName = firstName;
                entry.Property("FirstName").IsModified = true;
            }
            if (lastName != null)
            {
                doctor.LastName = lastName;
                entry.Property("LastName").IsModified = true;
            }
            if (email != null)
            {
                doctor.Email = email;
                entry.Property("Email").IsModified = true;
            }
            _context.SaveChanges();
        }
コード例 #2
0
        public HelperRequest UpdateDoctor(UpdateDoctorRequest request)
        {
            var helper = new HelperRequest();

            var countDoctor = _context.Doctors.Count(doc =>
                                                     doc.LastName == request.LastName && doc.FirstName == request.FirstName);

            if (countDoctor == 0)
            {
                helper.Number = 0;
                return(helper);
            }

            var doctor = new Doctor
            {
                FirstName = request.FirstName,
                LastName  = request.LastName,
                Email     = request.Email,
            };

            _context.Attach(doctor);
            _context.Entry(doctor).Property("FirstName").IsModified = true;
            _context.Entry(doctor).Property("LastName").IsModified  = true;
            _context.Entry(doctor).Property("Email").IsModified     = true;

            _context.SaveChangesAsync();

            helper.Number = 1;

            return(helper);
        }
コード例 #3
0
        public IActionResult UpdateDoctor(UpdateDoctorRequest request, int idDoctor)
        {
            var doctor = new Doctor {
                IdDoctor = idDoctor
            };

            _context.Attach(doctor);

            if (request.FirstName != null)
            {
                doctor.FirstName = request.FirstName;
                _context.Entry(doctor).Property("FirstName").IsModified = true;
            }

            if (request.LastName != null)
            {
                doctor.LastName = request.LastName;
                _context.Entry(doctor).Property("LastName").IsModified = true;
            }

            if (request.Email != null)
            {
                doctor.Email = request.Email;
                _context.Entry(doctor).Property("Email").IsModified = true;
            }

            _context.SaveChanges();

            string uri = $"/api/doctors/{doctor.IdDoctor}";

            return(Created(uri, doctor));
        }
コード例 #4
0
        public async Task <IActionResult> PutAsync(UpdateDoctorRequest request, CancellationToken cancellationToken)
        {
            _logger.LogInformation("Patients/Put was requested.");
            var response = await unitOfWork.Doctors.UpdateAsync(_mapper.Map <DoctorDTO>(request));

            unitOfWork.Save();
            return(Ok(_mapper.Map <DoctorResponce>(response)));
        }
コード例 #5
0
ファイル: DoctorProcess.cs プロジェクト: jdirosa7/UAI-MCGA
        public Doctor Update(Doctor doctor)
        {
            var request = new UpdateDoctorRequest();

            request.Doctor = doctor;
            var response = HttpPost <UpdateDoctorRequest>("api/doctor/update", request, MediaType.Json);

            return(doctor);
        }
コード例 #6
0
        public IActionResult UpdateDoctor([FromRoute] int id, [FromBody] UpdateDoctorRequest newDoctorRequest)
        {
            var modifiedEntries = _dbService.UpdateDoctor(id, newDoctorRequest);

            if (modifiedEntries == 0)
            {
                return(BadRequest("No entries were modified, probably wrong ID was requested."));
            }
            return(Ok($"{modifiedEntries} entries changed."));
        }
コード例 #7
0
ファイル: DoctorController.cs プロジェクト: s16061/APBDcw11
        public IActionResult UpdateDoctor(int id, UpdateDoctorRequest request)
        {
            var doc = _context.Doctors.Where(d => d.IdDoctor == id).FirstOrDefault();

            doc.FirstName = request.FirstName;
            doc.LastName  = request.LastName;
            doc.Email     = request.Email;
            _context.SaveChanges();
            return(Ok("Updated"));
        }
コード例 #8
0
ファイル: DoctorsController.cs プロジェクト: s19205/Cw10
 public IActionResult UpdateDoctor(UpdateDoctorRequest request)
 {
     if (dbService.UpdateDoctor(request))
     {
         return(Ok("DOCTOR DATA WAS UPDATED"));
     }
     else
     {
         return(BadRequest("WRONG DATA"));
     }
 }
コード例 #9
0
 public IActionResult UpdateDoctor(UpdateDoctorRequest req)
 {
     try
     {
         return(Ok(_service.UpdateDoctor(req)));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
コード例 #10
0
        public IActionResult UpdateDoctor(UpdateDoctorRequest updateDoctorRequest)
        {
            HelperRequest helper = _context.UpdateDoctor(updateDoctorRequest);

            switch (helper.Number)
            {
            case 0:
                return(BadRequest("Doctor with this Name and Lastname not exist"));

            default:
                return(Ok("Doctor modify"));
            }
        }
コード例 #11
0
ファイル: EfcClinicDbService.cs プロジェクト: s18277/cw11
        public int UpdateDoctor(int id, UpdateDoctorRequest newDoctorRequest)
        {
            var doctor = GetDoctor(id);

            if (doctor == null)
            {
                return(0);
            }
            doctor.FirstName = newDoctorRequest.FirstName ?? doctor.FirstName;
            doctor.LastName  = newDoctorRequest.LastName ?? doctor.LastName;
            doctor.Email     = newDoctorRequest.Email ?? doctor.Email;
            return(_context.SaveChanges());
        }
コード例 #12
0
 public void delete(UpdateDoctorRequest request)
 {
     try
     {
         var response = new UpdateDoctorResponse();
         var bc       = new DoctorComponent();
         bc.Update(request.Doctor);
     }
     catch (Exception ex)
     {
         var httpError = new HttpResponseMessage()
         {
             StatusCode   = (HttpStatusCode)422,
             ReasonPhrase = ex.Message
         };
         throw new HttpResponseException(httpError);
     }
 }
コード例 #13
0
        public Doctor UpdateDoctor(UpdateDoctorRequest request)
        {
            var doctor = _hospitalContext.Doctors.FirstOrDefault(d => d.IdDoctor == request.IdDoctor);

            if (doctor != null)
            {
                doctor.FirstName = request.FirstName;
                doctor.LastName  = request.LastName;
                doctor.Email     = request.Email;

                _hospitalContext.Update(doctor);
                _hospitalContext.SaveChanges();

                return(doctor);
            }
            else
            {
                return(null);
            }
        }
コード例 #14
0
        public Doctor UpdateDoctor(UpdateDoctorRequest request)
        {
            var d = _db.Doctor.Where(e => e.IdDoctor == request.IdDoctor).FirstOrDefault();

            if (d != null)
            {
                d.FirstName = request.FirstName;
                d.LastName  = request.LastName;
                d.Email     = request.Email;

                _db.Update(d);
                _db.SaveChanges();

                return(d);
            }
            else
            {
                return(null);
            }
        }
コード例 #15
0
        public bool UpdateDoctor(UpdateDoctorRequest request)
        {
            try
            {
                var el = dbContext.Doctors.Where(e => e.IdDoctor == request.IdDoctor).FirstOrDefault();
                if (el == null)
                {
                    return(false);
                }

                el.FirstName = request.FirstName;
                el.LastName  = request.LastName;
                el.Email     = request.Email;
                dbContext.SaveChanges();
                return(true);
            } catch (Exception ex)
            {
                return(false);
            }
        }
コード例 #16
0
ファイル: DoctorController.cs プロジェクト: s16451/APBD
        public IActionResult UpdateDoctor(int id, UpdateDoctorRequest request)
        {
            var doctor = _context.Doctor.SingleOrDefault(d => d.IdDoctor == id);

            if (doctor == null)
            {
                return(BadRequest("Doctor nie istnieje"));
            }

            _context.Attach(doctor);
            if (request.IdDoctor != null)
            {
                doctor.IdDoctor = request.IdDoctor.Value;
                _context.Entry(doctor).Property("IdDoctor").IsModified = true;
            }
            if (request.FirstName != null)
            {
                doctor.FirstName = request.FirstName;
                _context.Entry(doctor).Property("FirstName").IsModified = true;
            }
            if (request.LastName != null)
            {
                doctor.FirstName = request.LastName;
                _context.Entry(doctor).Property("LastName").IsModified = true;
            }
            if (request.Email != null)
            {
                doctor.Email = request.Email;
                _context.Entry(doctor).Property("Email").IsModified = true;
            }
            if (request.Prescriptions != null)
            {
                doctor.Prescriptions = request.Prescriptions;
                _context.Entry(doctor).Property("Prescriptions").IsModified = true;
            }

            _context.SaveChanges();

            return(Ok("Aktualizacja ukończona"));
        }
コード例 #17
0
        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();
        }
コード例 #18
0
        public void UpdateDoctor(UpdateDoctorRequest request)
        {
            var doctor = new Doctor {
                IdDoctor = request.IdDoctor
            };

            DbContext.Attach(doctor);
            if (request.FirstName != null)
            {
                doctor.FirstName = request.FirstName;
                DbContext.Entry(doctor).Property("FirstName").IsModified = true;
            }
            if (request.LastName != null)
            {
                doctor.LastName = request.LastName;
                DbContext.Entry(doctor).Property("LastName").IsModified = true;
            }
            if (request.Email != null)
            {
                doctor.Email = request.Email;
                DbContext.Entry(doctor).Property("Email").IsModified = true;
            }
            DbContext.SaveChanges();
        }
コード例 #19
0
        public Doctor UpdateDoctor(UpdateDoctorRequest req)
        {
            var doc = _context.Doctors.Find(req.IdDoctor);

            if (doc == null)
            {
                throw new Exception("nie znaleziono doktora");
            }

            if (req.FirstName != null)
            {
                doc.FirstName = req.FirstName;
            }

            if (req.LastName != null)
            {
                doc.LastName = req.LastName;
            }

            if (req.Email != null)
            {
                doc.Email = req.Email;
            }

            if (req.Prescriptions != null)
            {
                foreach (Prescription p in req.Prescriptions)
                {
                    doc.Prescriptions.Add(p);
                }
            }

            _context.SaveChanges();

            return(doc);
        }
コード例 #20
0
 public async Task <DoctorDto> EditAsync(UpdateDoctorRequest doctor)
 {
     return((await _httpService.HttpPutAsync <UpdateDoctorResponse>("doctors", doctor)).Doctor);
 }
コード例 #21
0
 public IActionResult UpdateDoctor(UpdateDoctorRequest request, int id)
 {
     _service.UpdateDoctor(request, id);
     return(Ok());
 }
コード例 #22
0
ファイル: DoctorsController.cs プロジェクト: s18885/apbd
 public IActionResult UpdateDoctor(UpdateDoctorRequest request)
 {
     _dbService.UpdateDoctor(request);
     return(Ok());
 }
コード例 #23
0
ファイル: DoctorsController.cs プロジェクト: s14324/APBD-cw11
 public IActionResult UpdateDoctor(UpdateDoctorRequest request)
 {
     return(Ok(_service.UpdateDoctor(request)));
 }