public ActionResult AddVillage(watershed_village data) { if (DAL.VillageDataDal.AddVillage(data) == true) { ViewData.Add("AddVillage", "success"); } else { ViewData.Add("AddVillage", "fail"); } return View(); }
public static watershed_village getVillage(watershed_village vil) { watershedEntities db = new watershedEntities(); try { return((from u in db.watershed_village where u.Name == vil.Name && u.tid == vil.tid select u).SingleOrDefault()); } catch (DbEntityValidationException ex) { return(null); } }
public static bool AddVillage(watershed_village vil) { watershedEntities db = new watershedEntities(); if (null == getVillage(vil)) { try { db.watershed_village.Add(vil); db.SaveChanges(); }catch (DbEntityValidationException ex) { return(false); } return(true); } return(false); }