Exemple #1
0
        public ActionResult EnrolmentAction(int?id)
        {
            ViewBag.drpStudent = CommonController.drpStudent();
            ViewBag.drpBatch   = CommonController.drpBatch();

            if (id != 0)
            {
                Enrolment dataset = entities.Enrolments.Find(id);
                return(PartialView(dataset));
            }

            else
            {
                return(PartialView());
            }
        }
Exemple #2
0
        public ActionResult EnrolmentAction(Enrolment enrolment)
        {
            ModelState.Remove("EnrolmentID");

            if (ModelState.IsValid)
            {
                string msg = "";

                if (enrolment.EnrolmentID > 0)
                {
                    var dataset = entities.Enrolments.Where(f => f.EnrolmentID == enrolment.EnrolmentID).FirstOrDefault();
                    if (dataset != null)
                    {
                        dataset.Date          = enrolment.Date;
                        dataset.StudentID     = enrolment.StudentID;
                        dataset.LessonBatchID = enrolment.LessonBatchID;

                        msg = "Enrolment details Updated Successfully";
                    }
                }
                else
                {
                    entities.Enrolments.Add(enrolment);

                    msg = "New Enrollment Added successfully";
                }
                entities.SaveChanges();
                return(new JsonResult
                {
                    Data = new
                    {
                        success = true,
                        action = "Enrolment",
                        message = msg
                    },
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }
            ViewBag.drpStudent = CommonController.drpStudent();
            ViewBag.drpBatch   = CommonController.drpBatch();

            return(PartialView(enrolment));
        }