コード例 #1
0
        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));
        }
コード例 #2
0
        public ActionResult Edit(StudentModel student)
        {
            try
            {
                ProcessRecords processRecords = new ProcessRecords();
                processRecords.updateRecord(student);
                ViewBag.Message = "Record updated successfully";
            }
            catch (Exception)
            {
                throw;
            }

            return(View());
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        public ActionResult About()
        {
            List <StudentModel> sm = new List <StudentModel>();

            try
            {
                ProcessRecords processRecords = new ProcessRecords();
                sm = processRecords.FetchRecord();
            }
            catch (Exception)
            {
                throw;
            }

            return(View(sm));
        }
コード例 #5
0
 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"));
 }