Example #1
0
 public void EditPosition(Tbl_Introduce input)
 {
     using (var db = new ProjectWebEntities())
     {
         try
         {
             var model = db.Tbl_Introduce.Find(input.Id);
             model.Sequence        = input.Sequence > 0 ? input.Sequence : null;
             db.Entry(model).State = EntityState.Modified;
             db.SaveChanges();
         }
         catch (Exception ex)
         {
             logger.Error("An Error Happened! ", ex);
         }
     }
 }
Example #2
0
 public void ChangeIsHome(Tbl_Introduce input)
 {
     using (var db = new ProjectWebEntities())
     {
         try
         {
             var model = db.Tbl_Introduce.Find(input.Id);
             model.IsHome          = input.IsHome;
             db.Entry(model).State = EntityState.Modified;
             db.SaveChanges();
             db.pr_LogSystem_save("Cập nhật trạng thái nổi bật(" + model.Title + ")", "Cập nhật", "Introduce", User.Identity.Name);
             //Xóa cache
             CacheHelper.ClearAllOutputCache();
         }
         catch (Exception ex)
         {
             logger.Error("An Error Happened! ", ex);
         }
     }
 }
Example #3
0
        public ActionResult Create(Tbl_Introduce model)
        {
            using (var db = new ProjectWebEntities())
            {
                try
                {
                    if (model != null)
                    {
                        model.Url = Util.GenerateUrl(model.Title);
                        // create new
                        if (model.Id == 0)
                        {
                            db.Tbl_Introduce.Add(model);
                            db.SaveChanges();
                            db.pr_LogSystem_save("Thêm mới dữ liệu(ID = " + model.Id + ")", "Thêm mới", "Tin tức", User.Identity.Name);

                            //Repository.ClearCache(); // clear cache
                        }
                        else // update current
                        {
                            var menu = db.Tbl_MenuMultiLevel.FirstOrDefault(p => p.PageChildId == model.Id && p.PageId == GlobalVariables.MenuGioithieu);
                            if (menu != null)
                            {
                                menu.Url             = db.Tbl_MenuLink.Find(GlobalVariables.MenuGioithieu).Url + model.Url + "-" + model.Id;
                                db.Entry(menu).State = EntityState.Modified;
                            }
                            db.Entry(model).State = EntityState.Modified;
                            db.SaveChanges();
                            db.pr_LogSystem_save("Cập nhật dữ liệu(ID = " + model.Id + ")", "Cập nhật", "Tin tức", User.Identity.Name);
                        }
                    }
                    //Xóa cache
                    CacheHelper.ClearAllOutputCache();
                }
                catch (Exception ex)
                {
                    logger.Error("An Error Happened! ", ex);
                }
                return(RedirectToAction("Index", "Introduce"));
            }
        }
Example #4
0
 public ActionResult destroyIntroduce([DataSourceRequest] DataSourceRequest request, Tbl_Introduce model)
 {
     using (var db = new ProjectWebEntities())
     {
         try
         {
             var m = db.Tbl_Introduce.Find(model.Id);
             if (model != null)
             {
                 try
                 {
                     db.Tbl_Introduce.Remove(m);
                     db.SaveChanges();
                     // Write log system---------
                     db.pr_LogSystem_save("Xóa dữ liệu(ID = " + model.Id + ")", "Xóa", "Introduce", User.Identity.Name);
                 }
                 catch (Exception ex)
                 {
                     // Write log system---------
                     db.pr_LogSystem_save("Xóa dữ liệu(ID = " + model.Id + ")", "Xóa", "Introduce", User.Identity.Name);
                     logger.Error("An Error Happened! ", ex);
                 }
             }
             //Xóa cache
             CacheHelper.ClearAllOutputCache();
         }
         catch (Exception ex)
         {
             logger.Error("An Error Happened! ", ex);
         }
         return(Json(new[] { model }.ToDataSourceResult(request, ModelState)));
     }
 }