示例#1
0
 //common lib
 public bool Insert(content_category entity)
 {
     try
     {
         entity.created_at  = DateTime.Now;
         entity.modified_at = DateTime.Now;
         db.content_category.Add(entity);
         db.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
        public ActionResult Edit(content_category cate)
        {
            if (ModelState.IsValid)
            {
                var dao     = new content_category_dao();
                var session = (UserLogin)Session[CommonConstants.USER_SESSION];
                cate.modified_by = session.username;

                var result = dao.Update(cate);
                if (result)
                {
                    SetAlert(StaticResources.Resources.Pub_UpdateSucess, "success");
                    return(RedirectToAction("Index", "ContentCate"));
                }
                else
                {
                    ModelState.AddModelError("", StaticResources.Resources.UpdateContentCategoryFailed);
                }
            }
            return(View());
        }
示例#3
0
 public bool Update(content_category entity)
 {
     try
     {
         var info = db.content_category.Find(entity.id);
         info.name             = entity.name;
         info.meta_title       = entity.meta_title;
         info.display_order    = entity.display_order;
         info.seo_title        = entity.seo_title;
         info.modified_by      = entity.modified_by;
         info.modified_at      = DateTime.Now;
         info.meta_keyword     = entity.meta_keyword;
         info.meta_description = entity.meta_description;
         info.is_active        = entity.is_active;
         info.is_showhome      = entity.is_showhome;
         db.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }