public ActionResult AddExam(string id, string Exception) { ViewBag.Exception = Exception; ViewBag.CourseList = new SelectList(_course.GetAll(), "pkid", "CourseName"); ViewBag.DivisionList = new SelectList(_division.GetAll(), "pkid", "DivisioName"); ViewBag.ForceList = new SelectList(_force.GetAll(), "pkid", "ForceName"); Session["Menu"] = 4.ToString(); if (!String.IsNullOrWhiteSpace(id)) { int _id = Convert.ToInt32(id); tbl_Exam_Master model = _Exam.Get(_id); tbl_Exam_Masterss abc = new tbl_Exam_Masterss(); abc.pkid = model.pkid; abc.Exam_Name = model.Exam_Name; abc.Total_Marks = model.Total_Marks; abc.PassingMarks = model.PassingMarks; abc.ExamDuration = model.ExamDuration; abc.Passing_Percentage = model.Passing_Percentage; abc.Instruction = model.Instruction; abc.AttemptCount = model.AttemptCount; abc.StartDate = model.StartDate; abc.EndDate = model.EndDate; abc.DeclareResult = model.DeclareResult; abc.Negative_Masrking = model.Negative_Masrking; abc.RandonQuestion = model.RandonQuestion; abc.ResultAfterFinish = model.ResultAfterFinish; abc.Course_fkid = model.Course_fkid; abc.Division_fkid = model.Division_fkid; return(View(abc)); } return(View()); }
public ActionResult AddExam(tbl_Exam_Masterss model) { string exception = ""; int Exam_id = 0; try { if (model.pkid == 0) { tbl_Exam_Master abc = new tbl_Exam_Master(); abc.Exam_Name = model.Exam_Name; abc.ExamDuration = model.ExamDuration; abc.Passing_Percentage = model.Passing_Percentage; abc.Total_Marks = model.Total_Marks; abc.PassingMarks = model.PassingMarks; abc.Instruction = model.Instruction; abc.AttemptCount = model.AttemptCount; abc.StartDate = model.StartDate; abc.EndDate = model.EndDate; abc.DeclareResult = model.DeclareResult; abc.Negative_Masrking = model.Negative_Masrking; abc.RandonQuestion = model.RandonQuestion; abc.ResultAfterFinish = model.ResultAfterFinish; abc.Course_fkid = model.Course_fkid; abc.Division_fkid = model.Division_fkid; abc.Adddate = DateTime.Now; _Exam.Add(abc); Exam_id = _Exam.GetAll().Max(x => x.pkid); exception = "Save Successfully"; } else { int _id = Convert.ToInt32(model.pkid); tbl_Exam_Master abc = _Exam.Get(_id); abc.Exam_Name = model.Exam_Name; abc.ExamDuration = model.ExamDuration; abc.Passing_Percentage = model.Passing_Percentage; abc.Total_Marks = model.Total_Marks; abc.PassingMarks = model.PassingMarks; abc.Instruction = model.Instruction; abc.AttemptCount = model.AttemptCount; abc.StartDate = model.StartDate; abc.EndDate = model.EndDate; abc.DeclareResult = model.DeclareResult; abc.Negative_Masrking = model.Negative_Masrking; abc.RandonQuestion = model.RandonQuestion; abc.ResultAfterFinish = model.ResultAfterFinish; abc.Course_fkid = model.Course_fkid; abc.Division_fkid = model.Division_fkid; abc.Adddate = DateTime.Now; _Exam.Update(abc); exception = "Update Successfully"; Exam_id = _id; } if (model.RandonQuestion == false) { return(RedirectToAction("AddQuestionExam", "Exam", new { id = Exam_id, Exception = exception })); } else { return(RedirectToAction("AddAutomaticQuestionExam", "Exam", new { id = Exam_id, Exception = exception })); } } catch (Exception e) { Commonfunction.LogError(e, Server.MapPath("~/Log.txt")); exception = e.Message; return(RedirectToAction("ExamMaster", "Exam", new { Exception = exception })); } }