public ActionResult AddUpdateCity(ClsCountry cntry) { string message = ""; bool status = false; try { string returnId = "0"; string insertUpdateStatus = ""; if (cntry.CountryId > 0) { insertUpdateStatus = "Update"; } else { insertUpdateStatus = "Save"; } returnId = InsertUpdateCountryDb(cntry, insertUpdateStatus); if (returnId == "Success") { status = true; message = "User Type Successfully Updated"; } else { status = false; message = returnId; } } catch (Exception ex) { status = false; message = ex.Message.ToString(); } return(new JsonResult { Data = new { status = status, message = message } }); //string message = ""; //bool status = false; //clsCity city = new clsCity(); //try //{ // if (ccity.CityId > 0) // { // var res = db.tblCities.Where(x => x.CityId == ccity.CityId).FirstOrDefault(); // res.CityName = ccity.CityName; // res.CountryId = ccity.CountryId; // db.SaveChanges(); // } // else // { // tblCity cityy = new tblCity(); // cityy.CityName = ccity.CityName; // cityy.CountryId = ccity.CountryId; // db.tblCities.Add(cityy); // db.SaveChanges(); // } // status = true; //} //catch (Exception ex) //{ // message = ex.Message.ToString(); //} //return new JsonResult { Data = new { status = status, message = message } }; }