示例#1
0
        public JsonResult AddPatientVillage(VVillages location)
        {
            try
            {
                if (location.Villageid == 0 || location.Villageid == null)
                {
                    var addedvillage = _village.Add(new VVillages()
                    {
                        Village = location.Village,
                        Wardid  = location.Wardid
                    });

                    location.Villageid = addedvillage.ID;
                }

                if (location.Patientid == 0)
                {
                    return(Json(new { Result = "ERROR", Message = "Please Add Biodata First" }));
                }
                else
                {
                    //Update patient location
                    var village = _patient.AddPatientLocation(location.Patientid, location.Villageid.Value);
                    return(Json(new { Result = "OK", Records = village }));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { Result = "ERROR", Message = ex.Message }));
            }
        }
 public VVillages Add(VVillages village)
 {
     using (_context)
     {
         var newvillage = new Villages()
         {
             WardID  = village.Wardid,
             Village = village.Village,
             Active  = true
         };
         _context.Villages.Add(newvillage);
         _context.SaveChanges();
         village.ID = newvillage.ID;
         //village.Subcountyid = newvillage.Wards.SubCountyID;
         //village.Countyid = newvillage.Wards.SubCounties.CountyID;
         return(village);
     }
 }