public async Task <ActionResult> DeleteConfirmed(int id) { TSql_Categorys tSql_Categorys = await db.TSql_Categorys.FindAsync(id); db.TSql_Categorys.Remove(tSql_Categorys); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "IDCategory,CategoryName")] TSql_Categorys tSql_Categorys) { if (ModelState.IsValid) { db.Entry(tSql_Categorys).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(tSql_Categorys)); }
public async Task <ActionResult> Create([Bind(Include = "IDCategory,CategoryName")] TSql_Categorys tSql_Categorys) { if (ModelState.IsValid) { db.TSql_Categorys.Add(tSql_Categorys); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(tSql_Categorys)); }
// GET: Admin/TSql_Categorys/Delete/5 public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TSql_Categorys tSql_Categorys = await db.TSql_Categorys.FindAsync(id); if (tSql_Categorys == null) { return(HttpNotFound()); } return(View(tSql_Categorys)); }
// Search Category public ViewResult Search_Category(int?page, int?id) { int num = 36; int pagenum = (page ?? 1); TSql_Categorys tcate = db.TSql_Categorys.Find(id); if (tcate == null) { Response.StatusCode = 404; } List <TSql_Film_Category> tfc = db.TSql_Film_Category.Where(m => m.IDCategory == id).ToList(); if (tfc.Count == 0) { ViewBag.danger = "Not found"; } Session["Cate"] = tcate.CategoryName; ViewBag.success = "Have " + tfc.Count + " result"; return(View(tfc.OrderBy(m => m.TSql_Films.FilmName).ToPagedList(pagenum, num))); }