public ActionResult ExamModelGridViewPartialUpdate([ModelBinder(typeof(DevExpressEditorsBinder))] Qiyas.BusinessLogicLayer.Entity.PPM.ExamModel item) { if (ModelState.IsValid) { try { if (!ExamModelExists(item.Name, item.ExamModelID)) { BusinessLogicLayer.Entity.PPM.ExamModel entity = new BusinessLogicLayer.Entity.PPM.ExamModel(item.ExamModelID); entity.Name = item.Name; entity.IsActive = item.IsActive; entity.ModifiedDate = DateTime.Now; entity.Save(); } else { ViewData["EditError"] = Resources.MainResource.ExamModelExists; } } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = Resources.MainResource.PleaseCorrectErrors; } var model = new BusinessLogicLayer.Components.PPM.ExamModelLogic().GetAll(); return(PartialView("_ExamModelGridViewPartial", model)); }
private bool ExamModelExists(string name, int id) { var currentUser = new BusinessLogicLayer.Entity.PPM.ExamModel(id); var checkUser = new BusinessLogicLayer.Components.PPM.ExamModelLogic().GetByName(name); if (checkUser == null) { return(false); } if (!currentUser.HasObject && checkUser != null) { return(true); } else if (currentUser.HasObject && checkUser != null && currentUser.ExamModelID != checkUser.ExamModelID) { return(true); } return(false); }
public ActionResult ExamModelGridViewPartialDelete(System.Int32 ExamModelID) { if (ExamModelID >= 0) { try { BusinessLogicLayer.Components.PPM.ExamModelLogic logic = new BusinessLogicLayer.Components.PPM.ExamModelLogic(); if (!logic.HasDependencies(ExamModelID)) { BusinessLogicLayer.Entity.PPM.ExamModel type = new BusinessLogicLayer.Entity.PPM.ExamModel(ExamModelID); type.Delete(); } } catch (Exception e) { ViewData["EditError"] = e.Message; } } var model = new BusinessLogicLayer.Components.PPM.ExamModelLogic().GetAll(); return(PartialView("_ExamModelGridViewPartial", model)); }
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)); }
public ActionResult ExamModelGridViewPartial() { var model = new BusinessLogicLayer.Components.PPM.ExamModelLogic().GetAll(); return(PartialView("_ExamModelGridViewPartial", model)); }