コード例 #1
0
        public async Task <ObjectResult> PostAsync([FromBody] PatientModel patientModelObj)
        {
            if (patientModelObj == null || !patientModelObj.ValidatePatientModel())
            {
                return(BadRequest(BuildStringFromResource("First Name, SurName & Genders are Mandatory")));
            }

            var patientEntity = _map.Map <PatientModel, PatientEntity>(patientModelObj, new PatientEntity());

            var patientDataActionResult = await _patient.AddPatients(patientEntity);

            if (!patientDataActionResult.IsSuccess)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, BuildStringFromResource("UnexpectedServerError")));
            }
            return(Ok(patientDataActionResult.PatientEntity));
        }