public ActionResult Create(IFormCollection collection) { try { if (ModelState.IsValid) { Student objstudent = new Student(); objstudent.Id = int.Parse(collection["Id"]); objstudent.Name = collection["Name"]; objstudent.RollNo = int.Parse(collection["RollNo"]); StudentDB objDB = new StudentDB(); var students = objDB.InsertValues(objstudent.Id, objstudent.Name, objstudent.RollNo); // TODO: Add insert logic here return(RedirectToAction(nameof(Index))); } else { return(View()); } } catch (Exception ex) { return(View(ex)); } }
//public ActionResult Edit(int id, IFormCollection collection) //public ActionResult Edit(int id, string name, int rollNo) public ActionResult Edit(Student student) { try { // TODO: Add update logic here Student objstudent = new Student(); objstudent.Id = student.Id; // int.Parse(collection["Id"]); objstudent.Name = student.Name; // name;// collection["Name"]; objstudent.RollNo = student.RollNo; // rollNo;// int.Parse(collection["RollNo"]); StudentDB objDB = new StudentDB(); var students = objDB.InsertValues(objstudent.Id, objstudent.Name, objstudent.RollNo); // TODO: Add insert logic here return(RedirectToAction(nameof(Index))); } catch { return(View()); } }