public async Task <PatientDTO> PutAsync(PatientCreateDTO patient) { this.Logger.LogTrace($"{nameof(this.PutAsync)} called"); var result = await this.PatientService.CreateAsync(this.Mapper.Map <PatientUpdateModel>(patient)); return(this.Mapper.Map <PatientDTO>(result)); }
public PatientDTO CreatePatient(PatientCreateDTO info) { StoreContext db = new StoreContext(); Patient patient = mapper.Map <Patient>(info); Patient test = db.Patient.Where(u => u.Idnumber == info.Idnumber).FirstOrDefault(); if (patient != null && test == null) { db.Patient.Add(patient); db.SaveChanges(); Patient patientResponse = db.Patient .Where(s => s.PatientId == patient.PatientId) .Include(u => u.User) .Include(b => b.BloodType) .Include(s => s.Status) .FirstOrDefault(); PatientDTO response = mapper.Map <PatientDTO>(patientResponse); return(response); } else { return(null); } }
public Patient ConvertPatientCreateDTOToPatient(PatientCreateDTO patient) { return(new Patient { Id = 0, Name = patient.Name, Surname = patient.Surname, Pesel = patient.Pesel, VisitsId = new List <int>() }); }
public ActionResult CreatePatient(PatientCreateDTO patient) { if (patient == null) { return(BadRequest()); } Patient pat = _pMapper.ConvertPatientCreateDTOToPatient(patient); _patients.CreateNewPatient(pat); return(Ok()); }
public IActionResult CreatePatient([FromBody] PatientCreateDTO info) { PatientDTO response = repository.CreatePatient(info); if (response != null) { return(new ObjectResult(response)); } else { return(new BadRequestObjectResult("Try again, you missed some of the needed informations.")); } }