示例#1
0
 public ActionResult TblGalleryDelete(long id)
 {
     try
     {
         TblGallery o = new TblGallery();
         o.Id = id;
         new TblGalleryDao().Delete(o);
         return(Json(JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         logger.Info(ControllerName + "::TblGalleryDelete::" + ex.Message);
         return(RedirectToAction("Index", "Error"));
     }
 }
示例#2
0
 public ActionResult TblGalleryUpdate(long id, TblGallery model)
 {
     try
     {
         TblGallery o = new TblGallery();
         o.Id       = id;
         o.Name     = model.Name;
         o.ImageUrl = model.ImageUrl;
         new TblGalleryDao().Update(o);
         SetAlert("cập nhật thành công", "success");
         return(RedirectToAction("TblGalleryListIndex", "Admin"));
     }
     catch (Exception ex)
     {
         logger.Info(ControllerName + "::TblGalleryUpdate::" + ex.Message);
         return(RedirectToAction("Index", "Error"));
     }
 }
示例#3
0
 public ActionResult TblGalleryCreate(TblGalleryModel model)
 {
     try
     {
         TblGallery o = new TblGallery();
         o.Name       = model.name;
         o.ImageUrl   = model.url;
         o.CreateUser = GetUserName();
         o.Createdate = DateTime.Now;
         new TblGalleryDao().Create(o);
         SetAlert("cập nhật thành công", "success");
         return(RedirectToAction("TblGalleryListIndex", "Admin"));
     }
     catch (Exception ex)
     {
         logger.Info(ControllerName + "::TblGalleryCreate::" + ex.Message);
         return(RedirectToAction("Index", "Error"));
     }
 }
示例#4
0
 public void Create(TblGallery o)
 {
     try
     {
         using (TkSchoolDbContext db = new TkSchoolDbContext())
         {
             db.TblGalleries.Add(o);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         if (ex.InnerException == null)
         {
             throw new Exception("TblGallery::Create::" + ex.Message);
         }
         else
         {
             throw new Exception("TblGallery::Create::" + ex.InnerException.Message);
         }
     }
 }
示例#5
0
 public void Delete(TblGallery o)
 {
     try
     {
         using (TkSchoolDbContext db = new TkSchoolDbContext())
         {
             var res = db.TblGalleries.Where(x => x.Id == o.Id).SingleOrDefault();
             db.TblGalleries.Remove(res);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         if (ex.InnerException == null)
         {
             throw new Exception("TblGallery::Delete::" + ex.Message);
         }
         else
         {
             throw new Exception("TblGallery::Delete::" + ex.InnerException.Message);
         }
     }
 }