05791423bd
Refresh tab e metodi in genere...
128 lines
3.7 KiB
C#
128 lines
3.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.Entity;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using StockManMVC.Models;
|
|
|
|
namespace StockManMVC.Controllers
|
|
{
|
|
public class ItemFamiliesController : Controller
|
|
{
|
|
private StockManEntities db = new StockManEntities();
|
|
|
|
// GET: ItemFamilies
|
|
public ActionResult Index()
|
|
{
|
|
return View(db.ItemFamily.ToList());
|
|
}
|
|
|
|
// GET: ItemFamilies/Details/5
|
|
public ActionResult Details(string id)
|
|
{
|
|
if (id == null)
|
|
{
|
|
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
|
}
|
|
ItemFamily itemFamily = db.ItemFamily.Find(id);
|
|
if (itemFamily == null)
|
|
{
|
|
return HttpNotFound();
|
|
}
|
|
return View(itemFamily);
|
|
}
|
|
|
|
// GET: ItemFamilies/Create
|
|
public ActionResult Create()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
// POST: ItemFamilies/Create
|
|
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
|
|
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
|
|
[HttpPost]
|
|
[ValidateAntiForgeryToken]
|
|
public ActionResult Create([Bind(Include = "ID,Descr")] ItemFamily itemFamily)
|
|
{
|
|
if (ModelState.IsValid)
|
|
{
|
|
db.ItemFamily.Add(itemFamily);
|
|
db.SaveChanges();
|
|
return RedirectToAction("Index");
|
|
}
|
|
|
|
return View(itemFamily);
|
|
}
|
|
|
|
// GET: ItemFamilies/Edit/5
|
|
public ActionResult Edit(string id)
|
|
{
|
|
if (id == null)
|
|
{
|
|
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
|
}
|
|
ItemFamily itemFamily = db.ItemFamily.Find(id);
|
|
if (itemFamily == null)
|
|
{
|
|
return HttpNotFound();
|
|
}
|
|
return View(itemFamily);
|
|
}
|
|
|
|
// POST: ItemFamilies/Edit/5
|
|
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
|
|
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
|
|
[HttpPost]
|
|
[ValidateAntiForgeryToken]
|
|
public ActionResult Edit([Bind(Include = "ID,Descr")] ItemFamily itemFamily)
|
|
{
|
|
if (ModelState.IsValid)
|
|
{
|
|
db.Entry(itemFamily).State = EntityState.Modified;
|
|
db.SaveChanges();
|
|
return RedirectToAction("Index");
|
|
}
|
|
return View(itemFamily);
|
|
}
|
|
|
|
// GET: ItemFamilies/Delete/5
|
|
public ActionResult Delete(string id)
|
|
{
|
|
if (id == null)
|
|
{
|
|
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
|
}
|
|
ItemFamily itemFamily = db.ItemFamily.Find(id);
|
|
if (itemFamily == null)
|
|
{
|
|
return HttpNotFound();
|
|
}
|
|
return View(itemFamily);
|
|
}
|
|
|
|
// POST: ItemFamilies/Delete/5
|
|
[HttpPost, ActionName("Delete")]
|
|
[ValidateAntiForgeryToken]
|
|
public ActionResult DeleteConfirmed(string id)
|
|
{
|
|
ItemFamily itemFamily = db.ItemFamily.Find(id);
|
|
db.ItemFamily.Remove(itemFamily);
|
|
db.SaveChanges();
|
|
return RedirectToAction("Index");
|
|
}
|
|
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
if (disposing)
|
|
{
|
|
db.Dispose();
|
|
}
|
|
base.Dispose(disposing);
|
|
}
|
|
}
|
|
}
|