Esempio n. 1
0
        public JsonResult Create(VPatients patient)
        {
            try
            {
                //if (!ModelState.IsValid)
                //{
                //    return Json(new { Result = "ERROR", Message = "Form is not valid! Please correct it and try again." });

                //}

                if (patient.Occupationid == 0 || patient.Occupationid == null)
                {
                    var addedoccupation = _occupation.Add(new VOccupations()
                    {
                        Occupation = patient.Occupation
                    });

                    patient.Occupationid = addedoccupation.ID;
                }

                if (patient.ID == 0)
                {
                    //Add patient biodata
                    patient = _patient.AddBiodata(patient);
                    return(Json(new { Result = "OK", Record = patient }));
                }
                else
                {
                    //Update patient biodata
                    _patient.UpdateBiodata(patient);
                    return(Json(new { Result = "OK" }));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { Result = "ERROR", Message = ex.Message }));
            }
        }