public JsonResult Index(StudentModel studentModel) { string message = ""; try { if (!ModelState.IsValid) { //return View(); } ProcessRecords processRecords = new ProcessRecords(); message = processRecords.InsertRecordInStudentTable(studentModel); if (message != "") { //ViewBag.Message = message; } else { //ViewBag.Message = "Data recorded successfully"; message = "Data recorded successfully"; //ModelState.Clear(); } } catch (Exception) { //Catch exception in text file //ViewBag.Message = "Error occured while inserting reocrd"; message = "Error occured while inserting reocrd"; } return(Json(message, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit(StudentModel student) { try { ProcessRecords processRecords = new ProcessRecords(); processRecords.updateRecord(student); ViewBag.Message = "Record updated successfully"; } catch (Exception) { throw; } return(View()); }
public ActionResult Edit(int id = 0) { StudentModel sm = new StudentModel(); try { ProcessRecords processRecords = new ProcessRecords(); sm = processRecords.FetchRecordId(id); } catch (Exception) { throw; } return(View(sm)); }
public ActionResult About() { List <StudentModel> sm = new List <StudentModel>(); try { ProcessRecords processRecords = new ProcessRecords(); sm = processRecords.FetchRecord(); } catch (Exception) { throw; } return(View(sm)); }
public ActionResult Delete(int id) { try { if (!ModelState.IsValid) { return(RedirectToAction("About")); } ProcessRecords processRecords = new ProcessRecords(); processRecords.DeleteRecord(id); } catch (Exception) { throw; } return(RedirectToAction("About")); }