Пример #1
0
        public ActionResult <PatientReadDTO> CreatePatient([FromBody] Patient pat)
        {
            //Check if patient exists
            var patientFromRepo = _repository.GetPatientByDniRaw(pat.Dni);

            if (patientFromRepo != null)
            {
                return(new BadRequestObjectResult(new { message = "Existing Entity", currentDate = DateTime.Now }));
            }

            _repository.CreatePatient(pat);
            _repository.SaveChanges();

            var patient = _mapper.Map <PatientReadDTO>(pat);

            return(Created("https://cotecapi.com/patients", patient));
        }