public ActionResult CreateBook() { if ((string)Session["role"] == "admin" || Convert.ToInt32(Session["id"]) == 1) { ViewBag.Genre = GenreAction.Get_All_Genre(); return(View()); } else { return(Redirect("~/Book/ShowBook")); } }
public ActionResult EditBook(int Id) { if ((string)Session["role"] == "admin" || (string)Session["role"] == "staff") { ViewBag.Book = BookAction.Find_Book(Id); ViewBag.Genre = GenreAction.Get_All_Genre(); return(View()); } else { return(Redirect("~/Book/ShowBook")); } }
public ActionResult BookManager() { if ((string)Session["role"] == "admin" || (string)Session["role"] == "staff") { using (var db = new DBShop()) { int page_number = db.DbBook.Where(item => item.flag == false).Count(); ViewBag.PageNumber = (page_number / page_size) + (page_number % page_size == 0 ? 0 : 1); ViewBag.Genre = GenreAction.Get_All_Genre(); db.Dispose(); } return(View()); } else { return(Redirect("~/Book/ShowBook")); } }
/* RESTORE DATA */ public ActionResult RestoreData() { if ((string)Session["role"] == "admin") { using (var db = new DBShop()) { int page_customer = db.DbCustomer.Where(item => item.flag == true).Count(); int page_book = db.DbBook.Where(item => item.flag == true).Count(); db.Dispose(); ViewBag.Customer = page_customer / page_size + (page_customer % page_size == 0 ? 0 : 1); ViewBag.Book = page_book / page_size + (page_book % page_size == 0 ? 0 : 1); ViewBag.Genre = GenreAction.Restore_Genre(); } return(View()); } else { return(Redirect("~/Book/ShowBook")); } }
/* Find Genre By ID */ public JsonResult GetdGenre(int ID) { return(Json(GenreAction.Find_By_ID(ID), JsonRequestBehavior.AllowGet)); }
/* Validation Genre By Name */ public JsonResult ValidGenre(string Name) { return(Json(GenreAction.Find_By_Name(Name), JsonRequestBehavior.AllowGet)); }
/* RESTORE GENRES WERE DELETED */ public ActionResult UnlockGenre(int ID) { GenreAction.Unlock_Genre(ID); RecordAction.Create_Record(CustomerAction.Find_Customer((int)Session["id"]).email, CustomerAction.Find_Customer((int)Session["id"]).email + " restorer genre" + GenreAction.Find_By_ID(ID).genre, DateTime.Now.Date); return(Redirect("~/Home/RestoreData")); }
/* DELETE GENRE */ public ActionResult DeleteGenre(int ID) { GenreAction.Lock_Genre(ID); RecordAction.Create_Record(CustomerAction.Find_Customer((int)Session["id"]).email, CustomerAction.Find_Customer((int)Session["id"]).email + " delete genre" + GenreAction.Find_By_ID(ID).genre, DateTime.Now.Date); return(Redirect("~/Book/BookManager/" + Session["id"])); }
public ActionResult UpdateGenre(int ID, string Name) { GenreAction.Update_Genre(ID, Name); RecordAction.Create_Record(CustomerAction.Find_Customer((int)Session["id"]).email, CustomerAction.Find_Customer((int)Session["id"]).email + " update genre " + Name, DateTime.Now.Date); return(Redirect("~/Book/BookManager")); }