public Qiyas.BusinessLogicLayer.Entity.PPM.Exam GetByCode(string Code) { Qiyas.BusinessLogicLayer.Entity.PPM.Exam examType = null; var ex = db.Exams.Where(c => c.ExamCode == Code).FirstOrDefault(); if (ex != null) { examType = new Entity.PPM.Exam(ex); } return(examType); }
public ActionResult ExamGridViewPartialAddNew([ModelBinder(typeof(DevExpressEditorsBinder))] Qiyas.BusinessLogicLayer.Entity.PPM.Exam item) { if (ModelState.IsValid) { try { if (!ExamExists(item.ExamCode, item.ExamID)) { BusinessLogicLayer.Entity.PPM.Exam exam = new BusinessLogicLayer.Entity.PPM.Exam(); exam.ExamCode = item.ExamCode; exam.ExamSpecialityID = item.ExamSpecialityID; exam.ExamTypeID = item.ExamTypeID; exam.Notes = item.Notes; exam.NumberofPages = item.NumberofPages; exam.NumberofSections = item.NumberofSections; exam.StudentGenderID = item.StudentGenderID; exam.TimeForSection = item.TimeForSection; exam.Name = item.Name; exam.ExamTypeID = item.ExamTypeID; exam.IsActive = item.IsActive; exam.ModifiedDate = DateTime.Now; exam.CreatedDate = DateTime.Now; exam.Save(); string[] itemsExamModels = Request["ExamModelCheckBoxList"].Split('|'); var examModels = new BusinessLogicLayer.Components.PPM.ExamModelLogic().GetAll(); for (int i = 1; i < itemsExamModels.Length; i++) { int examModelIndex = 0; if (i == itemsExamModels.Length - 1) { Int32.TryParse(itemsExamModels[i], out examModelIndex); } else { Int32.TryParse(itemsExamModels[i].Remove(itemsExamModels[i].Length - 1, 1), out examModelIndex); } BusinessLogicLayer.Entity.PPM.ExamModelItem mitem = new BusinessLogicLayer.Entity.PPM.ExamModelItem(); mitem.ExamID = exam.ExamID; mitem.ExamModelID = examModels[examModelIndex].ExamModelID; mitem.Save(); } } else { ViewData["EditError"] = Resources.MainResource.ExamExists; } } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { string msgError = ""; foreach (ModelState modelState in ViewData.ModelState.Values) { foreach (ModelError error in modelState.Errors) { msgError += error.ErrorMessage + " "; } } ViewData["EditError"] = msgError; //ViewData["EditError"] = Resources.MainResource.PleaseCorrectErrors; } var model = new BusinessLogicLayer.Components.PPM.ExamLogic().GetAllView(); return(PartialView("_ExamGridViewPartial", model)); }