public ActionResult Edit(m_information model)
 {
     if (ModelState.IsValid)
     {
         var dao    = new contentDao();
         var result = dao.update(model);
         if (result)
         {
             return(RedirectToAction("Index", "Content"));
         }
         else
         {
             ModelState.AddModelError("", "Cập nhập không thành công");
         }
     }
     SetViewBag(model.IdCategory);
     return(View("Index"));
 }
 public ActionResult Create(m_information model)
 {
     if (ModelState.IsValid)
     {
         var  dao = new contentDao();
         long id  = dao.Insert(model);
         if (id > 0)
         {
             return(RedirectToAction("Index", "Content"));
         }
         else
         {
             ModelState.AddModelError("", "Thêm user thành công");
         }
     }
     SetViewBag();
     return(View());
 }
예제 #3
0
 public bool update(m_information ennity)
 {
     try
     {
         var c = db.m_information.Find(ennity.Id);
         c.Name       = ennity.Name;
         c.Metatile   = ennity.Metatile;
         c.content    = ennity.content;
         c.Status_I   = ennity.Status_I;
         c.IdCategory = ennity.IdCategory;
         c.CreateBy   = ennity.CreateBy;
         c.CreateDate = ennity.CreateDate;
         db.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
예제 #4
0
 public long Insert(m_information content)
 {
     db.m_information.Add(content);
     db.SaveChanges();
     return(content.Id);
 }