c03b2707a4
con qualche scaffolding fatto...
128 lines
3.5 KiB
C#
128 lines
3.5 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 MovTypesController : Controller
|
|
{
|
|
private StockManEntities db = new StockManEntities();
|
|
|
|
// GET: MovTypes
|
|
public ActionResult Index()
|
|
{
|
|
return View(db.MovType.ToList());
|
|
}
|
|
|
|
// GET: MovTypes/Details/5
|
|
public ActionResult Details(string id)
|
|
{
|
|
if (id == null)
|
|
{
|
|
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
|
}
|
|
MovType movType = db.MovType.Find(id);
|
|
if (movType == null)
|
|
{
|
|
return HttpNotFound();
|
|
}
|
|
return View(movType);
|
|
}
|
|
|
|
// GET: MovTypes/Create
|
|
public ActionResult Create()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
// POST: MovTypes/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")] MovType movType)
|
|
{
|
|
if (ModelState.IsValid)
|
|
{
|
|
db.MovType.Add(movType);
|
|
db.SaveChanges();
|
|
return RedirectToAction("Index");
|
|
}
|
|
|
|
return View(movType);
|
|
}
|
|
|
|
// GET: MovTypes/Edit/5
|
|
public ActionResult Edit(string id)
|
|
{
|
|
if (id == null)
|
|
{
|
|
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
|
}
|
|
MovType movType = db.MovType.Find(id);
|
|
if (movType == null)
|
|
{
|
|
return HttpNotFound();
|
|
}
|
|
return View(movType);
|
|
}
|
|
|
|
// POST: MovTypes/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")] MovType movType)
|
|
{
|
|
if (ModelState.IsValid)
|
|
{
|
|
db.Entry(movType).State = EntityState.Modified;
|
|
db.SaveChanges();
|
|
return RedirectToAction("Index");
|
|
}
|
|
return View(movType);
|
|
}
|
|
|
|
// GET: MovTypes/Delete/5
|
|
public ActionResult Delete(string id)
|
|
{
|
|
if (id == null)
|
|
{
|
|
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
|
}
|
|
MovType movType = db.MovType.Find(id);
|
|
if (movType == null)
|
|
{
|
|
return HttpNotFound();
|
|
}
|
|
return View(movType);
|
|
}
|
|
|
|
// POST: MovTypes/Delete/5
|
|
[HttpPost, ActionName("Delete")]
|
|
[ValidateAntiForgeryToken]
|
|
public ActionResult DeleteConfirmed(string id)
|
|
{
|
|
MovType movType = db.MovType.Find(id);
|
|
db.MovType.Remove(movType);
|
|
db.SaveChanges();
|
|
return RedirectToAction("Index");
|
|
}
|
|
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
if (disposing)
|
|
{
|
|
db.Dispose();
|
|
}
|
|
base.Dispose(disposing);
|
|
}
|
|
}
|
|
}
|