Пример #1
0
 private IEnumerable<ErrorInfo> Validate(DocumentType documentType)
 {
     return ValidationHelper.Validate(documentType);
 }
Пример #2
0
 public ActionResult UpdateDocumentType(FormCollection collection)
 {
     EditDocumentTypeModel model=new EditDocumentTypeModel();
     ResultModel resultModel=new ResultModel();
     this.TryUpdateModel(model);
     string ErrorMessage=DocumentTypeAvailable(model.DocumentTypeName,model.DocumentTypeID);
     if(String.IsNullOrEmpty(ErrorMessage)==false) {
         ModelState.AddModelError("Name",ErrorMessage);
     }
     if(ModelState.IsValid) {
         DocumentType documentType=AdminRepository.FindDocumentType(model.DocumentTypeID);
         if(documentType==null) {
             documentType=new DocumentType();
         }
         documentType.EntityID=Authentication.CurrentEntity.EntityID;
         documentType.DocumentTypeName=model.DocumentTypeName;
         documentType.DocumentSectionID=model.DocumentSectionID;
         IEnumerable<ErrorInfo> errorInfo=AdminRepository.SaveDocumentType(documentType);
         if(errorInfo!=null) {
             resultModel.Result+=ValidationHelper.GetErrorInfo(errorInfo);
         } else {
             resultModel.Result="True||"+documentType.DocumentTypeID;
         }
     } 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);
 }