public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Photo")] CategoryTbl categoryTbl) { if (id != categoryTbl.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(categoryTbl); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryTblExists(categoryTbl.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(categoryTbl)); }
public ActionResult DeleteConfirmed(long id) { CategoryTbl categoryTbl = db.CategoryTbls.Find(id); db.CategoryTbls.Remove(categoryTbl); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "CategoryID,MainCategoryID,CategoryName")] CategoryTbl categoryTbl) { if (ModelState.IsValid) { db.Entry(categoryTbl).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MainCategoryID = new SelectList(db.MainCategoryTbls, "MainCategoryID", "MainCategory", categoryTbl.MainCategoryID); return(View(categoryTbl)); }
public async Task <IActionResult> Create([Bind("Id,Name,Photo")] CategoryTbl categoryTbl) { if (ModelState.IsValid) { _context.Add(categoryTbl); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(categoryTbl)); }
public ActionResult Create([Bind(Include = "CategoryID,MainCategoryID,CategoryName")] CategoryTbl categoryTbl) { if (ModelState.IsValid) { db.CategoryTbls.Add(categoryTbl); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MainCategoryID = new SelectList(db.MainCategoryTbls, "MainCategoryID", "MainCategory", categoryTbl.MainCategoryID); return(View(categoryTbl)); }
public void save(CategoryVM vm) { try { CategoryTbl entity = new CategoryTbl(); entity.CategoryName = vm.CategoryName; _MarbalContext.Entry(entity).State = EntityState.Added; _MarbalContext.SaveChanges(); } catch (Exception ex) { throw ex; } }
// GET: Store/Category/Details/5 public ActionResult Details(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CategoryTbl categoryTbl = db.CategoryTbls.Find(id); if (categoryTbl == null) { return(HttpNotFound()); } return(View(categoryTbl)); }
// GET: Store/Category/Edit/5 public ActionResult Edit(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CategoryTbl categoryTbl = db.CategoryTbls.Find(id); if (categoryTbl == null) { return(HttpNotFound()); } ViewBag.MainCategoryID = new SelectList(db.MainCategoryTbls, "MainCategoryID", "MainCategory", categoryTbl.MainCategoryID); return(View(categoryTbl)); }
private void LoadForm() { //SelectedItem = _categoryTblService.GetAll().Where(c => c.Category_Kubun == 0).SingleOrDefault(); SelectCategory(); SelectedItem = Categorys[3]; }