public FormCategory(string buttonCategory) { InitializeComponent(); btnAddEditDelCat.Text = buttonCategory; category = new Category_(); if (btnAddEditDelCat.Text == "Dodaj") { labelNameCat.Visible = false; cbNameCategory.Visible = false; this.Text = "Dodaj kategorię"; } else { labelNameCat.Visible = true; cbNameCategory.Visible = true; setComboBox(); this.Text = "Edytuj kategorię"; if (btnAddEditDelCat.Text == "Usuń") { textBoxNameCategory.Visible = false; labelNameCategory.Visible = false; this.Text = "Usuń kategorię"; } } }
public ActionResult DeleteConfirmed(int id) { Category_ category_ = db.Category_.Find(id); db.Category_.Remove(category_); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "categoryId,categoryName")] Category_ category_) { if (ModelState.IsValid) { db.Entry(category_).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(category_)); }
public ActionResult Create([Bind(Include = "categoryId,categoryName")] Category_ category_) { if (ModelState.IsValid) { db.Category_.Add(category_); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(category_)); }
// GET: Category_/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Category_ category_ = db.Category_.Find(id); if (category_ == null) { return(HttpNotFound()); } return(View(category_)); }