Example #1
0
 public ActionResult CustomField()
 {
     ViewData["MenuName"]="AdminManagement";
     ViewData["SubmenuName"]="CustomFieldManagement";
     ViewData["PageName"]="CustomField";
     EditCustomFieldModel model=new EditCustomFieldModel();
     model.Modules=SelectListFactory.GetModuleSelectList(AdminRepository.GetAllModules());
     model.DataTypes=SelectListFactory.GetDataTypeSelectList(AdminRepository.GetAllDataTypes());
     model.OptionFields=new List<EditOptionFieldModel>();
     model.OptionFields.Add(new EditOptionFieldModel());
     return View(model);
 }
Example #2
0
 public ActionResult UpdateCustomField(FormCollection collection)
 {
     EditCustomFieldModel model=new EditCustomFieldModel();
     ResultModel resultModel=new ResultModel();
     this.TryUpdateModel(model);
     string ErrorMessage=CustomFieldTextAvailable(model.CustomFieldText,model.CustomFieldId,model.ModuleId);
     if(String.IsNullOrEmpty(ErrorMessage)==false) {
         ModelState.AddModelError("CustomFieldText",ErrorMessage);
     }
     if(ModelState.IsValid) {
         CustomField customField=AdminRepository.FindCustomField(model.CustomFieldId);
         if(customField==null) {
             customField=new CustomField();
         }
         customField.CustomFieldText=model.CustomFieldText;
         customField.DataTypeID=model.DataTypeId;
         customField.ModuleID=model.ModuleId;
         customField.OptionalText=model.OptionalText;
         customField.Search=model.Search;
         customField.EntityID=Authentication.CurrentEntity.EntityID;
         IEnumerable<ErrorInfo> errorInfo=AdminRepository.SaveCustomField(customField);
         if(errorInfo!=null) {
             resultModel.Result+=ValidationHelper.GetErrorInfo(errorInfo);
         } else {
             resultModel.Result="True||"+customField.CustomFieldID;
         }
     } else {
         foreach(var values in ModelState.Values.ToList()) {
             foreach(var err in values.Errors.ToList()) {
                 if(string.IsNullOrEmpty(err.ErrorMessage)==false) {
                     resultModel.Result+=err.ErrorMessage+"\n";
                 }
             }
         }
     }
     return View("Result",resultModel);
 }