Exemple #1
0
        public async Task <IActionResult> UpdatePatient([FromRoute] string regno, [FromBody] PatientDTO patient)
        {
            if (patient.payors.Count > 0)
            {
                var listOfPayors = new List <PatientPayorTypes>();
                foreach (var k in patient.payors)
                {
                    var current = k;
                    current.Patientid = regno;
                    listOfPayors.Add(current);
                }
                bool isDeleted = false;
                if (patientPayorTypes.count(x => x.Patientid == regno) > 0)
                {
                    isDeleted = patientPayorTypes.Delete(x => x.Patientid == regno);
                }

                patientPayorTypes.AddMultiples(listOfPayors.ToArray());

                //if (isDeleted)
                //{

                patient.Patientid = regno;
                var result = await ps.updatePatientInfo((Patient)patient);

                if (result)
                {
                    return(Ok(BaseResponse.GetResponse(null, "success", "00")));
                }
                // }
                return(BadRequest(BaseResponse.GetResponse(null, "request failed to update data try again", "99")));
            }

            patient.Patientid = regno;
            var ispatientUpdated = await ps.updatePatientInfo((Patient)patient);

            if (ispatientUpdated)
            {
                return(Ok(BaseResponse.GetResponse(null, "success", "00")));
            }



            return(BadRequest(BaseResponse.GetResponse(null, "request failed to update data try again", "99")));
        }