Example #1
0
 public ActionResult UpdateSecurityType(FormCollection collection)
 {
     EditSecurityTypeModel model=new EditSecurityTypeModel();
     ResultModel resultModel=new ResultModel();
     this.TryUpdateModel(model);
     string ErrorMessage=SecurityTypeNameAvailable(model.Name,model.SecurityTypeId);
     if(String.IsNullOrEmpty(ErrorMessage)==false) {
         ModelState.AddModelError("Name",ErrorMessage);
     }
     if(ModelState.IsValid) {
         SecurityType securityType=AdminRepository.FindSecurityType(model.SecurityTypeId);
         if(securityType==null) {
             securityType=new SecurityType();
         }
         securityType.Name=model.Name;
         securityType.Enabled=model.Enabled;
         IEnumerable<ErrorInfo> errorInfo=AdminRepository.SaveSecurityType(securityType);
         if(errorInfo!=null) {
             resultModel.Result+=ValidationHelper.GetErrorInfo(errorInfo);
         } else {
             resultModel.Result="True";
         }
     } 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);
 }
Example #2
0
 public ActionResult EditSecurityType(int id)
 {
     EditSecurityTypeModel model=new EditSecurityTypeModel();
     SecurityType securityType=AdminRepository.FindSecurityType(id);
     if(securityType!=null) {
         model.SecurityTypeId=securityType.SecurityTypeID;
         model.Name=securityType.Name;
         model.Enabled=securityType.Enabled;
     }
     return View(model);
 }