using System; using System.Collections.Generic; using System.Data; using System.Data.Entity; using System.Linq; using System.Threading.Tasks; using System.Net; using System.Web; using System.Web.Mvc; using HealthchoiceMVC.Models; namespace HealthchoiceMVC.Controllers { [Authorize(Roles = "SiteAdmin")] public class UserTypeController : Controller { private HCDBEntities db = new HCDBEntities(); // GET: user_type public async Task Index() { return View(await db.user_type.ToListAsync()); } // GET: user_type/Details/5 public async Task Details(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } user_type user_type = await db.user_type.FindAsync(id); if (user_type == null) { return HttpNotFound(); } return View(user_type); } // GET: user_type/Create public ActionResult Create() { return View(); } // POST: user_type/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 async Task Create([Bind(Include = "user_type_key,user_type_desc")] user_type user_type) { if (ModelState.IsValid) { db.user_type.Add(user_type); await db.SaveChangesAsync(); return RedirectToAction("Index"); } return View(user_type); } // GET: user_type/Edit/5 public async Task Edit(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } user_type user_type = await db.user_type.FindAsync(id); if (user_type == null) { return HttpNotFound(); } return View(user_type); } // POST: user_type/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 async Task Edit([Bind(Include = "user_type_key,user_type_desc")] user_type user_type) { if (ModelState.IsValid) { db.Entry(user_type).State = EntityState.Modified; await db.SaveChangesAsync(); return RedirectToAction("Index"); } return View(user_type); } // GET: user_type/Delete/5 public async Task Delete(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } user_type user_type = await db.user_type.FindAsync(id); if (user_type == null) { return HttpNotFound(); } return View(user_type); } // POST: user_type/Delete/5 [HttpPost, ActionName("Delete")] [ValidateAntiForgeryToken] public async Task DeleteConfirmed(int id) { user_type user_type = await db.user_type.FindAsync(id); db.user_type.Remove(user_type); await db.SaveChangesAsync(); return RedirectToAction("Index"); } protected override void Dispose(bool disposing) { if (disposing) { db.Dispose(); } base.Dispose(disposing); } } }