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 { public class NetworkAffiliationsController : Controller { private HCDBEntities db = new HCDBEntities(); // GET: NetworkAffiliations public async Task Index() { return View(await db.NetworkAffiliations.ToListAsync()); } // GET: NetworkAffiliations/Details/5 public async Task Details(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } NetworkAffiliation networkAffiliation = await db.NetworkAffiliations.FindAsync(id); if (networkAffiliation == null) { return HttpNotFound(); } return View(networkAffiliation); } // GET: NetworkAffiliations/Create public ActionResult Create() { return View(); } // POST: NetworkAffiliations/Create // To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://go.microsoft.com/fwlink/?LinkId=317598. [HttpPost] [ValidateAntiForgeryToken] public async Task Create([Bind(Include = "NetworkAffiliationId,NetworkName")] NetworkAffiliation networkAffiliation) { if (ModelState.IsValid) { db.NetworkAffiliations.Add(networkAffiliation); await db.SaveChangesAsync(); return RedirectToAction("Index"); } return View(networkAffiliation); } // GET: NetworkAffiliations/Edit/5 public async Task Edit(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } NetworkAffiliation networkAffiliation = await db.NetworkAffiliations.FindAsync(id); if (networkAffiliation == null) { return HttpNotFound(); } return View(networkAffiliation); } // POST: NetworkAffiliations/Edit/5 // To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://go.microsoft.com/fwlink/?LinkId=317598. [HttpPost] [ValidateAntiForgeryToken] public async Task Edit([Bind(Include = "NetworkAffiliationId,NetworkName")] NetworkAffiliation networkAffiliation) { if (ModelState.IsValid) { db.Entry(networkAffiliation).State = EntityState.Modified; await db.SaveChangesAsync(); return RedirectToAction("Index"); } return View(networkAffiliation); } // GET: NetworkAffiliations/Delete/5 public async Task Delete(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } NetworkAffiliation networkAffiliation = await db.NetworkAffiliations.FindAsync(id); if (networkAffiliation == null) { return HttpNotFound(); } return View(networkAffiliation); } // POST: NetworkAffiliations/Delete/5 [HttpPost, ActionName("Delete")] [ValidateAntiForgeryToken] public async Task DeleteConfirmed(int id) { NetworkAffiliation networkAffiliation = await db.NetworkAffiliations.FindAsync(id); db.NetworkAffiliations.Remove(networkAffiliation); await db.SaveChangesAsync(); return RedirectToAction("Index"); } protected override void Dispose(bool disposing) { if (disposing) { db.Dispose(); } base.Dispose(disposing); } } }