Link to home
Start Free TrialLog in
Avatar of mustish1
mustish1

asked on

Route config file

VS 2019 ASP.NET MVC
Can you please tell me why it's not displaying the EDIT Page?
User generated image

SchedulingController.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web.Mvc;
using Scheduling.Models;
using System.Data.Entity;
namespace Scheduling.Controllers
{
public class SchedulingController : Controller
{
private SchedulingContext db = new SchedulingContext();
// GET: Scheduling
public ActionResult Index()
{
List<Bks_DWH_TrainingProgramsBasicData> trainingPrograms = db.Bks_DWH_TrainingProgramsBasicData.ToList();
return View(trainingPrograms);
}
// GET: Scheduling/Details/5
public ActionResult Details(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Bks_DWH_TrainingProgramsBasicData trainingProgram = db.Bks_DWH_TrainingProgramsBasicData.Find(id);
if (trainingProgram == null)
{
return HttpNotFound();
}
return View(trainingProgram);
}
// GET: Scheduling/Create
public ActionResult Create()
{
return View();
}
// POST: Scheduling/Create
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(Bks_DWH_TrainingProgramsBasicData trainingProgram)
{
if (ModelState.IsValid)
{
db.Bks_DWH_TrainingProgramsBasicData.Add(trainingProgram);
db.SaveChanges();
return RedirectToAction("Index");
}
return View(trainingProgram);
}
// GET: Scheduling/Edit/5
public ActionResult Edit(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Bks_DWH_TrainingProgramsBasicData trainingProgram = db.Bks_DWH_TrainingProgramsBasicData.Find(id);
if (trainingProgram == null)
{
return HttpNotFound();
}
return View(trainingProgram);
}
// POST: Scheduling/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(Bks_DWH_TrainingProgramsBasicData trainingProgram)
{
if (ModelState.IsValid)
{
db.Entry(trainingProgram).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
return View(trainingProgram);
}
// GET: Scheduling/Delete/5
public ActionResult Delete(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Bks_DWH_TrainingProgramsBasicData trainingProgram = db.Bks_DWH_TrainingProgramsBasicData.Find(id);
if (trainingProgram == null)
{
return HttpNotFound();
}
return View(trainingProgram);
}
// POST: Scheduling/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public ActionResult DeleteConfirmed(int id)
{
Bks_DWH_TrainingProgramsBasicData trainingProgram = db.Bks_DWH_TrainingProgramsBasicData.Find(id);
db.Bks_DWH_TrainingProgramsBasicData.Remove(trainingProgram);
db.SaveChanges();
return RedirectToAction("Index");
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
db.Dispose();
}
base.Dispose(disposing);
}
}
}

--------------------------------------------------------------------------------------------
Edit.cshtml
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web.Mvc;
using Scheduling.Models;
using System.Data.Entity;
namespace Scheduling.Controllers
{
public class SchedulingController : Controller
{
private SchedulingContext db = new SchedulingContext();
// GET: Scheduling
public ActionResult Index()
{
List<Bks_DWH_TrainingProgramsBasicData> trainingPrograms = db.Bks_DWH_TrainingProgramsBasicData.ToList();
return View(trainingPrograms);
}
// GET: Scheduling/Details/5
public ActionResult Details(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Bks_DWH_TrainingProgramsBasicData trainingProgram = db.Bks_DWH_TrainingProgramsBasicData.Find(id);
if (trainingProgram == null)
{
return HttpNotFound();
}
return View(trainingProgram);
}
// GET: Scheduling/Create
public ActionResult Create()
{
return View();
}
// POST: Scheduling/Create
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(Bks_DWH_TrainingProgramsBasicData trainingProgram)
{
if (ModelState.IsValid)
{
db.Bks_DWH_TrainingProgramsBasicData.Add(trainingProgram);
db.SaveChanges();
return RedirectToAction("Index");
}
return View(trainingProgram);
}
// GET: Scheduling/Edit/5
public ActionResult Edit(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Bks_DWH_TrainingProgramsBasicData trainingProgram = db.Bks_DWH_TrainingProgramsBasicData.Find(id);
if (trainingProgram == null)
{
return HttpNotFound();
}
return View(trainingProgram);
}
// POST: Scheduling/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(Bks_DWH_TrainingProgramsBasicData trainingProgram)
{
if (ModelState.IsValid)
{
db.Entry(trainingProgram).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
return View(trainingProgram);
}
// GET: Scheduling/Delete/5
public ActionResult Delete(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Bks_DWH_TrainingProgramsBasicData trainingProgram = db.Bks_DWH_TrainingProgramsBasicData.Find(id);
if (trainingProgram == null)
{
return HttpNotFound();
}
return View(trainingProgram);
}
// POST: Scheduling/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public ActionResult DeleteConfirmed(int id)
{
Bks_DWH_TrainingProgramsBasicData trainingProgram = db.Bks_DWH_TrainingProgramsBasicData.Find(id);
db.Bks_DWH_TrainingProgramsBasicData.Remove(trainingProgram);
db.SaveChanges();
return RedirectToAction("Index");
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
db.Dispose();
}
base.Dispose(disposing);
}
}
}
---------------------------------------------------------------------------
RouteConfig.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
namespace Scheduling
{
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Scheduling", action = "Index", id = UrlParameter.Optional }
);
}
}
}

Open in new window


ASKER CERTIFIED SOLUTION
Avatar of it_saige
it_saige
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial