Esempio n. 1
0
        public override void Setup()
        {
            base.Setup();

            // Spin up mock repository and attach to controller
            MockService = new Mock<ISecurityTypeService>();

            DefaultSecurityType = new DeepBlue.Models.Entity.SecurityType(MockService.Object);
            MockService.Setup(x => x.SaveSecurityType(It.IsAny<DeepBlue.Models.Entity.SecurityType>()));
        }
Esempio n. 2
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);
 }
Esempio n. 3
0
 private IEnumerable<ErrorInfo> Validate(SecurityType securityType)
 {
     return ValidationHelper.Validate(securityType);
 }