public async Task <PatientDTO> PatchAsync(PatientUpdateDTO patient)
        {
            this.Logger.LogTrace($"{nameof(this.PutAsync)} called");
            var result = await this.PatientService.UpdateAsync(this.Mapper.Map <PatientUpdateModel>(patient));

            return(this.Mapper.Map <PatientDTO>(result));
        }
示例#2
0
        public async Task <IActionResult> PutPatient(int dni, [FromBody] PatientUpdateDTO request)
        {
            if (dni != request.DNI)
            {
                return(BadRequest());
            }

            var patientUpdate = _mapper.Map <PatientUpdateDTO, Patient>(request);
            await _PatientsService.ModifyPatientAsync(patientUpdate);

            var patientDTO = _mapper.Map <Patient, PatientDTO>(patientUpdate);

            return(Ok(patientDTO));
        }
        public IActionResult UpdatePatient([FromBody] PatientUpdateDTO info)
        {
            PatientDTO response = repository.UpdatePatient(info);

            if (response != null)
            {
                return(new ObjectResult(response));
            }

            else
            {
                return(new NotFoundObjectResult("The inserted ID in the body is not matching any patient."));
            }
        }
示例#4
0
        public PatientDTO UpdatePatient(PatientUpdateDTO info)
        {
            StoreContext db = new StoreContext();

            Patient patient = db.Patient
                              .Where(s => s.PatientId == Helper.DecryptInt(info.PatientId))
                              .Include(u => u.User)
                              .Include(b => b.BloodType)
                              .Include(s => s.Status)
                              .FirstOrDefault();

            if (patient != null)
            {
                Patient patientInfo = mapper.Map <Patient>(info);

                patient.UserId      = patientInfo.UserId;
                patient.Idnumber    = patientInfo.Idnumber;
                patient.Gender      = patientInfo.Gender;
                patient.DateOfBirth = patientInfo.DateOfBirth;
                patient.BloodTypeId = patientInfo.BloodTypeId;
                patient.PhoneNumber = patientInfo.PhoneNumber;
                patient.Address     = patientInfo.Address;
                patient.StatusId    = patientInfo.StatusId;

                db.SaveChanges();

                PatientDTO response = mapper.Map <PatientDTO>(patient);
                response.DateCreated = patient.DateCreated;

                return(response);
            }

            else
            {
                return(null);
            }
        }