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")); } }
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")); } }
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")); } }
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); } } }
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); } } }