public ActionResult Edit(T_Place T_Place)
 {
     if (ModelState.IsValid)
     {
         _db.Entry(T_Place).State = EntityState.Modified;
         _db.SaveChanges();
         Session["Result"] = "okE";
         return(RedirectToAction("Index"));
     }
     return(View(T_Place));
 }
        public ActionResult Create(T_Place data)
        {
            if (ModelState.IsValid)
            {
                var chk = _db.T_Place.FirstOrDefault(c => c.PlaceID == data.PlaceID);
                if (chk == null)
                {
                    _db.T_Place.Add(data);
                    _db.SaveChanges();
                    Session["Result"] = "okC";
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ModelState.AddModelError("CategoryID", "มีหมวดนี้อยู่ในฐานข้อมูลแล้ว กรุณาตรวจสอบอีกครั้ง");
                }
            }

            return(View(data));
        }
Пример #3
0
        public PlaceDTO Add(PlaceDTO place)
        {
            T_Place FruitResult = _dal.Insert <T_Place>(Mapper.Map <T_Place>(place));

            return(Mapper.Map <PlaceDTO>(FruitResult));
        }