public string SaveUpdateCountry(CountryModel model) { string msg = string.Empty; ShomaRMEntities db = new ShomaRMEntities(); if (model.ID == 0) { var saveCountry = new tbl_Country() { CountryName = model.CountryName, }; db.tbl_Country.Add(saveCountry); db.SaveChanges(); msg = "Progress Saved Successfully"; } else { var updateCountry = db.tbl_Country.Where(co => co.ID == model.ID).FirstOrDefault(); if (updateCountry != null) { updateCountry.CountryName = model.CountryName; db.SaveChanges(); msg = "Progress Updated Successfully"; } } db.Dispose(); return(msg); }
public string InsertOrUpdate(CountryModel CM) { string result = string.Empty; bool IsExsit = false; tbl_Country Country; Country = this.GetById(CM.CountryID); if (Country != null) { IsExsit = true; } else { Country = new tbl_Country(); } Country.CountryID = CM.CountryID; Country.CountryName = CM.CountryName; if (!IsExsit) { return(result = this.Insert(Country)); } else { return(result = this.Update(Country)); } }
public string InsertOrUpdateCountry(CountryModel CM) { tbl_Country Country = new tbl_Country(); Country.CountryID = CM.CountryID; Country.CountryName = CM.CountryName; return(CountryBL.InsertOrUpdate(CM)); }
// GET: Administrator/Country/Edit/5 public ActionResult Edit(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } tbl_Country tbl_Country = db.tbl_Country.Find(id); if (tbl_Country == null) { return HttpNotFound(); } return View(tbl_Country); }
public int AddNewCountry(CountryModel model) { var currentCountry = new tbl_Country { Country = model.Country, RefSite = model.RefSite, SpphIdCountry = model.SpphIdCountry }; this.db.TblCountry.Add(currentCountry); this.db.SaveChanges(); return(currentCountry.IdCountry); }
public ActionResult DeleteConfirmed(int id) { try { tbl_Country tbl_Country = db.tbl_Country.Find(id); db.tbl_Country.Remove(tbl_Country); db.SaveChanges(); } catch (Exception ex) { TempData["err"] = ex.Message; } return RedirectToAction("Index"); }
public PartialViewResult GetCountryById(int CountryID) { CountryModel CM = new CountryModel(); tbl_Country Country; Country = CountryBL.GetById(CountryID); if (Country == null) { Country = new tbl_Country(); } CM.CountryID = Country.CountryID; CM.CountryName = Country.CountryName; return(PartialView("~/Views/Country/Partial/_CountryDetailsPartial.cshtml", CM)); }
public CountryViewModel AddCountry(CountryViewModel entity) { var data = new tbl_Country { CountryId = entity.countryId, CountryName = entity.countryName, IsActive = entity.isActive, CreatedBy = "admin", CreatedOn = DateTime.Now, ModifiedBy = "admin", ModifiedOn = DateTime.Now }; context.tbl_Country.Add(data); context.SaveChanges(); return(entity); }
public ActionResult Edit([Bind(Include = "countryid,countryname")] tbl_Country tbl_Country) { if (ModelState.IsValid) { try { db.Entry(tbl_Country).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } catch (Exception ex) { TempData["err"] = ex.Message; } } return View(tbl_Country); }
/// <summary> /// Update Region /// </summary> /// <param name="Country"></param> /// <returns></returns> public string Update(tbl_Country country) { try { Context.Country.Update(country); Context.Country.Save(); return(country.CountryID + " Updated Successfully!!"); } catch (Exception ex) { //POS Log Exception to db table return("Error in saving details, Please try again!!"); } finally { // Context = null; } }
/// <summary> /// 国家名转国家id /// </summary> /// <param name="name">多个name用“/”隔开</param> /// <returns>转换后的国家id</returns> public static string CountryToId(string name) { using (MR_DataClassesDataContext _db = new MR_DataClassesDataContext()) { List <int> countries = new List <int>(); foreach (string item in name.Split('/')) { tbl_Country tblCountry = _db.tbl_Country.SingleOrDefault(p => p.country_Name == item); if (tblCountry == null) { countries.Add(_db.InsertCountry(item)); } else { countries.Add(_db.tbl_Country.SingleOrDefault(p => p.country_Name == item).country_Id); } } return(string.Join("/", countries)); } }
partial void Deletetbl_Country(tbl_Country instance);
partial void Updatetbl_Country(tbl_Country instance);
partial void Inserttbl_Country(tbl_Country instance);