コード例 #1
0
 public ActionResult AddVillage(watershed_village data)
 {
     if (DAL.VillageDataDal.AddVillage(data) == true)
     {
         ViewData.Add("AddVillage", "success");
     }
     else
     {
         ViewData.Add("AddVillage", "fail");
     }
     return View();
 }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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);
        }