using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Sample.New;
namespace Sample.New.Controllers
{
public class MyController : Controller
{
private EmployeeWDBEntities db = new EmployeeWDBEntities();
//
// GET: /My/
public ViewResult Index()
{
return View(db.TableEmployees.ToList());
}
//
// GET: /My/Details/5
public ViewResult Details(int id)
{
TableEmployee tableemployee = db.TableEmployees.Find(id);
return View(tableemployee);
}
//
// GET: /My/Create
public ActionResult Create()
{
return View();
}
//
// POST: /My/Create
[HttpPost]
public ActionResult Create(TableEmployee tableemployee)
{
if (ModelState.IsValid)
{
db.TableEmployees.Add(tableemployee);
db.SaveChanges();
return RedirectToAction("Index");
}
return View(tableemployee);
}
//
// GET: /My/Edit/5
public ActionResult Edit(int id)
{
TableEmployee tableemployee = db.TableEmployees.Find(id);
return View(tableemployee);
}
//
// POST: /My/Edit/5
[HttpPost]
public ActionResult Edit(TableEmployee tableemployee)
{
if (ModelState.IsValid)
{
db.Entry(tableemployee).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
return View(tableemployee);
}
//
// GET: /My/Delete/5
public ActionResult Delete(int id)
{
TableEmployee tableemployee = db.TableEmployees.Find(id);
return View(tableemployee);
}
//
// POST: /My/Delete/5
[HttpPost, ActionName("Delete")]
public ActionResult DeleteConfirmed(int id)
{
TableEmployee tableemployee = db.TableEmployees.Find(id);
db.TableEmployees.Remove(tableemployee);
db.SaveChanges();
return RedirectToAction("Index");
}
protected override void Dispose(bool disposing)
{
db.Dispose();
base.Dispose(disposing);
}
}
}