// -------------------------------------------------------------------------------------
        // Methods
        // -------------------------------------------------------------------------------------
        public FacadeResult CancelAccount(long id) {
#if DEBUG
            using (MiniProfiler.Current.Step("AccountFacade.CancelAccount")) {
#endif
                using (var context = new UnitOfWorkScope(TransactionMode.New)) {
                    var account = Account.GetById(id);

                    var validationResults = new AccountValidator()
                        .Validate(account);
                    if (validationResults.IsValid == true) {
                        account.IsActive = false;

                        User.GetAllByAccountId(id).ForEach(user => {
                            user.IsActive = false;

                            UserCacheManager.Put(user);
                        });

                        context.Commit();

                        AccountCacheManager.Put(account);

                        return new FacadeResult();
                    }

                    var error = validationResults.Errors
                        .First().ErrorMessage
                        .GetError();

                    return new FacadeResult(error);
#if DEBUG
                }
#endif
            }
        }
Пример #2
0
        public AccountsModule(
            GetAll getAll,
            GetById getById,
            CreateCommand create,
            UpdateCommand update,
            ExcludeCommand exclude,
            AccountValidator validator, 
            IMapper mapper)
            : base("accounts")
        {
            _getAll = getAll;
            _getById = getById;
            _create = create;
            _update = update;
            _exclude = exclude;
            _validator = validator;
            _mapper = mapper;

            this.RequiresAuthentication();

            Get["/", true] = All;
            Get["/{id}", true] = ById;
            Post["/", true] = Create;
            Put["/{id}", true] = Update;
            Delete["/{id}", true] = Exclude;
        }
        public void SetUp()
        {
            _validator = new AccountValidator();

            _modelStub = new Mock<Account>();
            _modelStub.Setup(m => m.Name).Returns("Junior Oliveira");
            _modelStub.Setup(m => m.Email).Returns("*****@*****.**");
            _modelStub.Setup(m => m.Password).Returns("123456");
            _modelStub.Setup(m => m.ConfirmPassword).Returns("123456");
        }
Пример #4
0
        public object Post(AccountModel request)
        {
            var session = this.GetSession();
            ValidationResult validations = new AccountValidator().Validate(request);
            if (!validations.IsValid)
            {
                request.ResponseResult.ResultStatus = ResultStatuses.Error;
                foreach (var item in validations.Errors)
                {
                    request.ResponseResult.Messages.Add(item.ErrorMessage);
                }

                return request;
            }

            string hash, salt;
            new SaltedHash().GetHashAndSaltString(request.Password, out hash, out salt);

            try
            {
                var roles = new List<string>();
                if (request.IsMember)
                {
                    roles.Add("Member");
                }
                else
                {
                    roles.Add("Author");
                }

                var newUser = UserAuthRepository.CreateUserAuth(new UserAuth
                {
                    DisplayName = request.UserName,
                    Email = request.Email,
                    FirstName = request.FirstName,
                    LastName = request.LastName,
                    PrimaryEmail = request.Email,
                    UserName = request.UserName,
                    Salt = salt,
                    PasswordHash = hash,
                    FullName = "{0} {1}".Fmt(request.FirstName, request.LastName),
                    Roles = roles
                }, request.Password);
            }
            catch (ArgumentException ex)
            {
                request.ResponseResult.ResultStatus = ResultStatuses.Error;
                request.ResponseResult.Messages.Add(ex.Message);

                return request;
            }

            request.ResponseResult.ResultStatus = ResultStatuses.Success;
            return request;
        }
        public (bool isValid, IEnumerable <ValidationResult> errors) Validate()
        {
            var validator = new AccountValidator();
            var result    = validator.Validate(this);

            if (result.IsValid)
            {
                return(true, null);
            }

            return(false, result.Errors.Select(item => new ValidationResult(item.ErrorMessage, new [] { item.PropertyName })));
        }
 public void SetUp()
 {
     _existingCustomers = new List <Customer>()
     {
         new CustomerBuilder(_random).WithId().Build(),
         new CustomerBuilder(_random).WithId().Build(),
         new CustomerBuilder(_random).WithId().Build()
     };
     _customerRepositoryMock = new Mock <ICustomerRepository>();
     _customerRepositoryMock.Setup(repo => repo.GetAllWithAccounts()).Returns(_existingCustomers);
     _validator = new AccountValidator(_customerRepositoryMock.Object);
 }
Пример #7
0
        public AccountValidatorTests()
        {
            context = new TestingContext();
            hasher  = Substitute.For <IHasher>();
            hasher.VerifyPassword(Arg.Any <String>(), Arg.Any <String>()).Returns(true);
            validator = new AccountValidator(new UnitOfWork(new TestingContext(context)), hasher);

            context.Add(account = ObjectsFactory.CreateAccount());
            context.SaveChanges();

            validator.CurrentAccountId = account.Id;
        }
        public AccountValidatorTests()
        {
            context = new TestingContext();
            hasher  = Substitute.For <IHasher>();
            hasher.VerifyPassword(Arg.Any <String>(), Arg.Any <String>()).Returns(true);

            context.DropData();
            SetUpData();

            validator = new AccountValidator(new UnitOfWork(context), hasher);
            validator.CurrentAccountId = account.Id;
        }
Пример #9
0
        public void SetUp()
        {
            context = new TestingContext();
            hasher  = Substitute.For <IHasher>();
            hasher.Verify(Arg.Any <String>(), Arg.Any <String>()).Returns(true);

            validator            = new AccountValidator(new UnitOfWork(context), hasher);
            validator.ModelState = new ModelStateDictionary();
            HttpContext.Current  = new HttpMock().HttpContext;

            TearDownData();
            SetUpData();
        }
Пример #10
0
        public void GivenFasterPaymentsRequest_AndAccountWithChaps_WhenValidatingAccount_ThenResultSuccessIsFalse()
        {
            MakePaymentRequest request = new MakePaymentRequest {
                PaymentScheme = PaymentScheme.FasterPayments
            };
            Account account = new Account()
            {
                AllowedPaymentSchemes = AllowedPaymentSchemes.Chaps
            };

            var result = AccountValidator.ValidateAccountCanSatisfyPaymentRequest(request, account);

            Assert.False(result.Success);
        }
Пример #11
0
        public void GivenBacsRequest_AndAccountWithBACSPermissions_WhenValidatingAccount_ThenResultSuccessIsTrue()
        {
            MakePaymentRequest request = new MakePaymentRequest {
                PaymentScheme = PaymentScheme.Bacs
            };
            Account account = new Account()
            {
                AllowedPaymentSchemes = AllowedPaymentSchemes.Bacs
            };

            var result = AccountValidator.ValidateAccountCanSatisfyPaymentRequest(request, account);

            Assert.True(result.Success);
        }
Пример #12
0
        public void CustomerId_Is_One_Is_Valid()
        {
            // Arrange
            var validator = new AccountValidator <Account>();
            var account   = new Account {
                CustomerId = 1
            };

            // Act
            var result = validator.Validate(account);

            // Assert
            Assert.False(result.Errors.Any(e => e.ErrorMessage == "CustomerId is required"));
        }
Пример #13
0
        private void CreateAccount()
        {
            var results = AccountValidator.Validate(ViewModel);

            if (!results.IsValid)
            {
                Android.Support.V7.App.AlertDialog         alertDialog = null;
                Android.Support.V7.App.AlertDialog.Builder builder     = new Android.Support.V7.App.AlertDialog.Builder(this)
                                                                         .SetTitle("Invalid Model")
                                                                         .SetMessage("- " + string.Join(" \n -", results.Errors.Select(x => x.ErrorMessage).ToList()))
                                                                         .SetPositiveButton("Ok", (object s, Android.Content.DialogClickEventArgs dialogClickEventArgs) =>
                {
                    alertDialog.Hide();
                });

                alertDialog = builder.Create();
                alertDialog.Show();
            }
            else
            {
                try
                {
                    var db = new SQLiteConnection(DBPath);

                    var insert = db.Insert(new Account()
                    {
                        Password    = ViewModel.Password,
                        UserName    = ViewModel.UserName,
                        FirstName   = ViewModel.FirstName,
                        LastName    = ViewModel.LastName,
                        PhoneNumber = ViewModel.PhoneNumber,
                        ServiceDate = ViewModel.ServiceStartDate.Value
                    });

                    if (insert == 1)
                    {
                        var intent = new Intent(this, typeof(ConfirmationActivity));
                        StartActivity(intent);
                    }
                    else
                    {
                        //TODO: Let the user know the database wasn't updated
                    }
                }
                catch (Exception ex)
                {
                    //TODO: Let the user know something went wrong
                }
            }
        }
        /// <summary>
        /// Insert a new Account
        /// </summary>
        public Account Insert(Account account)
        {
            // hash the given password
            account.Password = GetPasswordHash(account.Password);

            // validate the new account
            var validator = new AccountValidator(m_accounts);
            var validationresults = validator.Validate(account, ruleSet: "default,Insert");

            if (!validationresults.IsValid)
                throw new ValidationException(validationresults.Errors);

            return m_accounts.Insert(account);
        }
Пример #15
0
        public void CustomerId_Is_Zero_Generates_Error()
        {
            // Arrange
            var validator = new AccountValidator <Account>();
            var account   = new Account {
                CustomerId = 0
            };

            // Act
            var result = validator.Validate(account);

            // Assert
            Assert.True(result.Errors.Any(e => e.ErrorMessage == "CustomerId is required"));
        }
Пример #16
0
        public void GivenFasterPaymentsRequest_AndAccountWithFasterPermissions_AndBalanceLessThatnAmount_WhenValidatingAccount_ThenResultSuccessIsFalse()
        {
            MakePaymentRequest request = new MakePaymentRequest {
                PaymentScheme = PaymentScheme.FasterPayments, Amount = 10
            };
            Account account = new Account()
            {
                AllowedPaymentSchemes = AllowedPaymentSchemes.FasterPayments, Balance = 9
            };

            var result = AccountValidator.ValidateAccountCanSatisfyPaymentRequest(request, account);

            Assert.False(result.Success);
        }
Пример #17
0
        public OpResult UpdateAccount(string userName, AccountUpdateRequest dto)
        {
            var account = _repo.GetFirst <Account>(a => a.UserName == userName, null, "Profiles");

            if (account == null)
            {
                return(OpResult.FailureResult("Account not found"));
            }

            var profile = account.GetProfile();

            if (profile == null)
            {
                if (!(string.IsNullOrEmpty(dto.FirstName) && string.IsNullOrWhiteSpace(dto.LastName)))
                {
                    profile = new Profile();
                    account.Profiles.Add(profile);
                }
            }
            if (profile != null)
            {
                profile.FirstName = dto.FirstName;
                profile.LastName  = dto.LastName;
            }

            if (account.Email != dto.Email)
            {
                var anotherAccount = _repo.GetFirst <Account>(a => a.ID != dto.Id && a.Email == dto.Email, null, "Profiles");
                if (anotherAccount != null)
                {
                    return(OpResult.FailureResult("eMail already exists"));
                }

                account.Email = dto.Email;
            }

            AccountValidator validator = new AccountValidator();
            var validationResult       = validator.Validate(account);

            if (!validationResult.IsValid)
            {
                return(OpResult.FailureResult(validationResult.Errors.Select(e => e.ErrorMessage).ToList()));
            }

            _repo.Update <Account>(account);
            _repo.Save();

            return(OpResult.SuccessResult());
        }
Пример #18
0
        public void GivenChapsRequest_AndAccountWithChapsPermissions_AndDISABLEDAccount_WhenValidatingAccount_ThenResultSuccessIsFalse()
        {
            MakePaymentRequest request = new MakePaymentRequest {
                PaymentScheme = PaymentScheme.Chaps
            };
            Account account = new Account()
            {
                AllowedPaymentSchemes = AllowedPaymentSchemes.Chaps,
                Status = AccountStatus.Disabled
            };

            var result = AccountValidator.ValidateAccountCanSatisfyPaymentRequest(request, account);

            Assert.False(result.Success);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="info"></param>
        /// <returns></returns>
        public async Task <dynamic> ChangeIntroduction(long userid, DTOAPI_ChangeIntroduction info)
        {
            if (!AccountValidator.bValidIntroduction(info.introduction))
            {
                throw new Exception("简介不符合规则");
            }

            await this.publishEndpoint.Publish(new ChangeAccountIntroductionCommand
            {
                id           = userid,
                introduction = info.introduction
            });

            return("");
        }
Пример #20
0
        private bool IsValidAccountPassword()
        {
            BCryptHashGenerator bCryptHashGenerator = new BCryptHashGenerator();
            string hashedPassword = bCryptHashGenerator.GenerateHashedString(accountCurrent.Password, accountReceived.Salt);

            accountCurrent.Password = hashedPassword;
            _password = hashedPassword;
            AccountValidator          accountValidator     = new AccountValidator(accountReceived);
            ValidationResult          dataValidationResult = accountValidator.Validate(accountCurrent);
            IList <ValidationFailure> validationFailures   = dataValidationResult.Errors;
            UserFeedback userFeedback = new UserFeedback(FormGrid, validationFailures);

            userFeedback.ShowFeedback();
            return(dataValidationResult.IsValid);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="info"></param>
        /// <returns></returns>
        public async Task <dynamic> ChangeNickName(long userid, DTOAPI_ChangeNickName info)
        {
            if (!AccountValidator.bValidDisplayName(info.nickName))
            {
                throw new Exception("昵称不符合规则");
            }

            await this.publishEndpoint.Publish(new ChangeAccountNickNameCommand
            {
                id       = userid,
                nickName = info.nickName
            });

            return("");
        }
Пример #22
0
        public void TestFasterPaymentsAccountAndPaymentSchemeIsFasterPaymentsInsufficientFundsIsValid()
        {
            // Get Live Bacs Account
            Account account = GetDummyAccount(AccountStatus.Live, AllowedPaymentSchemes.FasterPayments, Convert.ToDecimal(25.42));

            // Get Bacs Request
            MakePaymentRequest request = new MakePaymentRequest
            {
                Amount        = Convert.ToDecimal(30.50),
                PaymentScheme = PaymentScheme.FasterPayments
            };

            var result = AccountValidator.CheckAccountIsValid(account, request);

            Assert.IsFalse(result);
        }
Пример #23
0
        public void TestBacsAccountAndPaymentSchemeIsNotBacsIsValid()
        {
            // Get Live Bacs Account
            Account account = GetDummyAccount(AccountStatus.Live, AllowedPaymentSchemes.Bacs, Convert.ToDecimal(200.43));

            // Get Bacs Request
            MakePaymentRequest request = new MakePaymentRequest
            {
                Amount        = Convert.ToDecimal(30.50),
                PaymentScheme = PaymentScheme.Chaps
            };

            var result = AccountValidator.CheckAccountIsValid(account, request);

            Assert.IsFalse(result);
        }
Пример #24
0
        public void TestNullAccountAndPaymentSchemeIsBacsIsValid()
        {
            // Get Null Account
            Account account = null;

            // Get Bacs Request
            MakePaymentRequest request = new MakePaymentRequest
            {
                Amount        = Convert.ToDecimal(30.50),
                PaymentScheme = PaymentScheme.Bacs
            };

            var result = AccountValidator.CheckAccountIsValid(account, request);

            Assert.IsFalse(result);
        }
Пример #25
0
        //private RepositoryPlaceholder _repo = new RepositoryPlaceholder();

        public OpResult CreateAccount(AccountCreateRequest dto)
        {
            Account account = new Account
            {
                UserName = dto.Username,
                Password = dto.Password,
                Email    = dto.Email,
                EmailVerificationCode = Guid.NewGuid().ToString("N")
            };

            AccountValidator validator = new AccountValidator();
            var validationResult       = validator.Validate(account);

            if (!validationResult.IsValid)
            {
                return(OpResult.FailureResult(validationResult.Errors.Select(e => e.ErrorMessage).ToList()));
            }

            var existingAccount = _repo.GetFirst <Account>(a => a.UserName == dto.Username || a.Email == dto.Email);

            if (existingAccount != null)
            {
                if (existingAccount.UserName == dto.Username)
                {
                    return(OpResult.FailureResult("username already exists"));
                }
                if (existingAccount.Email == dto.Email)
                {
                    return(OpResult.FailureResult("eMail already exists"));
                }
            }

            var salt       = EncryptionUtil.GenerateRandomSaltString();
            var hashedPass = EncryptionUtil.GeneratePBKDF2Hash(dto.Password, salt);

            account.PasswordHash = hashedPass;
            account.PasswordSalt = salt;

            _repo.Create <Account>(account);
            _repo.Save();

            _emailService.SendEmail(_configService.GetFromEmailAddress(), _configService.GetFromEmailName(),
                                    account.Email, "Verify Account", "Your verification code is " + account.EmailVerificationCode);

            return(OpResult.SuccessResult());
        }
Пример #26
0
        public async Task Validate_OneAccount()
        {
            using (var provider = await CreateProvider())
            {
                var access   = provider.GetRequiredService <IContextLock>();
                var accounts = provider.GetRequiredService <IAccountRepository>();
                IValidator <Account> validator = new AccountValidator(accounts);
                var account = new Account();

                using (await access.Read())
                {
                    var target = new ValidationTarget <Account>(account);
                    validator.Validate(target);
                    Assert.False(target.GetResult().HasErrors);
                }
            }
        }
Пример #27
0
        public async Task <Guid> Handle(CreateAccountCommand command, CancellationToken cancellationToken)
        {
            var user = await _userRepository.Get(command.UserId);

            var account = new Account(user);

            var validator = new AccountValidator();
            var result    = await validator.ValidateAsync(account, default);

            if (!result.IsValid)
            {
                throw new Exception("Model invalid.");
            }

            await _accountRepository.Insert(account);

            return(account.Id);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="registerInfo"></param>
        /// <returns></returns>
        public async Task <long> RegisterByEmailVerifyCode(DTOAPI_RegisterByEmailVerifyCode registerInfo)
        {
            if (!EmailHepler.IsValid(registerInfo.email))
            {
                throw new Exception("邮箱格式不正确");
            }

            if (!AccountValidator.bValidPassword(registerInfo.pwd))
            {
                throw new Exception("密码格式错误");
            }

            string key_captcha = $"RegisterCaptcha_{registerInfo.email.ToLower()}";
            string captcha     = this.captchaHelper.GetCaptcha(key_captcha);

            if (String.IsNullOrEmpty(captcha) ||
                !String.Equals(captcha, registerInfo.verifyCode, StringComparison.CurrentCultureIgnoreCase))
            {
                throw new Exception("验证码错误");
            }

            var account = this.accesser.Get(email: registerInfo.email).Item1;

            if (account != null)
            {
                throw new Exception("用户已存在");
            }

            var newId = this.IDGenerator.GetNewID <Account>();

            await this.publishEndpoint.Publish(new RegisterAccountByEmailCommand
            {
                id       = newId,
                email    = registerInfo.email.ToLower(),
                password = registerInfo.pwd
            });

            await this.publishEndpoint.Publish(new DeleteAccountCaptchaCommand
            {
                key = key_captcha
            });

            return(newId);
        }
        protected override void OnStartup(StartupEventArgs e)
        {
            var context = new BankContext();

            context.CreateOrUpdateDatabase();

            var customerRepository = new CustomerRepository(context);
            var cityRepository     = new CityRepository(context);
            var accountRepository  = new AccountRepository(context);

            var customerValidator = new CustomerValidator(cityRepository);
            var accountValidator  = new AccountValidator(customerRepository);

            var dialogService = new WindowDialogService(accountRepository, accountValidator);

            var customersWindow = new CustomersWindow(customerRepository, customerValidator, cityRepository, dialogService);

            customersWindow.Show();
        }
Пример #30
0
        public ActionResult Signin(SigninViewModel model)
        {
            var validator = new AccountValidator();

            validator.LogEventHandler += HandleLogEvents;

            if (!validator.IsValidCredentials(model.Username, model.Password))
            {
                LogError($"Login validation failed for {nameof(model.Username)}: {model.Username} using {nameof(model.Password)}: {model.Password}.");
                return(View(new SigninViewModel {
                    IsFailedAuthentication = true
                }));
            }

            LogMessage($"Login validation succeded for {nameof(model.Username)}: {model.Username} using {nameof(model.Password)}: {model.Password}.");
            CurrentLoginData = model;
            TsUserName       = model.Username;

            LogMessage($"Redirecting to {Url.Action("SelectSite", "Account")}.");
            return(RedirectToAction("SelectSite", "Account"));
        }
Пример #31
0
        static void Main(string[] args)
        {
            var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());

            XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));

            TripRepository    tripRepository    = new TripRepository();
            TripValidator     tripValidator     = new TripValidator();
            AccountRepository accountRepository = new AccountRepository();
            AccountValidator  accountValidator  = new AccountValidator();
            BookingRepository bookingRepository = new BookingRepository();
            BookingValidator  bookingValidator  = new BookingValidator();
            ITripServices     tripServices      = new TripServicesImpl(accountRepository, tripRepository, bookingRepository,
                                                                       accountValidator, tripValidator, bookingValidator);

            TripServicesGrpcImpl tripServicesGrpc = new TripServicesGrpcImpl(tripServices);
            GrpcServer           server           = new GrpcServer(int.Parse(ConfigurationManager.AppSettings["port"]),
                                                                   ConfigurationManager.AppSettings["host"], tripServicesGrpc);

            server.Start();
        }
Пример #32
0
 static void Main(string[] args)
 {
     LOGGER.Info("loading application context");
     try
     {
         AccountRepository accountRepository = new AccountRepository();
         TripRepository    tripRepository    = new TripRepository();
         BookingRepository bookingRepository = new BookingRepository();
         BookingValidator  bookingValidator  = new BookingValidator();
         AccountValidator  accountValidator  = new AccountValidator();
         TripValidator     tripValidator     = new TripValidator();
         ITripServices     tripServices      = new TripServicesImpl(accountRepository, tripRepository, bookingRepository, accountValidator, tripValidator, bookingValidator);
         AbstractServer    server            = new RpcConcurrentServer(ConfigurationManager.AppSettings["host"],
                                                                       Int32.Parse(ConfigurationManager.AppSettings["port"]), tripServices);
         server.Start();
     }
     catch (Exception ex)
     {
         LOGGER.Warn(ex.StackTrace);
     }
 }
Пример #33
0
        public Account Save(Account entity)
        {
            ;

            var errorList = new List <ValidationFailure>();

            SetLogInfo(entity);
            var errorEntity = AccountValidator.GetInstance().Validate(entity);

            errorList.AddRange(errorEntity.Errors);

            if (errorList.Count != 0)
            {
                throw new SpadException(string.Join(",", errorList.Select(s => s.ErrorMessage)));
            }


            var result = _repository.Save(entity);

            return(entity);
        }
Пример #34
0
        public string ValidateCredentials([FromBody] UserInfoDTO data)
        {
            var DTO    = new UserInfoDTO();
            int status = AccountValidator.compareCredentials(data.email, data.password);

            if (status == 1)   //valid credentials
            {
                string token;
                // check to see if user has a token already
                if (SessionController.sm.ifUserExists(data.email))
                {
                    token = SessionController.sm.getToken(data.email);
                }
                else
                {
                    // generate token for user
                    SessionController.sm.updateToken(data.email);
                    token = SessionController.sm.getToken(data.email);
                }

                DTO.status = "200";                              //Set the status
                DTO        = DTO.getUserInfo(data.email, token); //Get the user info for return
                string output = JsonConvert.SerializeObject(DTO);

                return(output);
            }
            else if (status == 0)   //invalid credentials
            {
                DTO.status = "400";
                string output = JsonConvert.SerializeObject(DTO);
                return(output);
            }
            else    //Null error
            {
                DTO.status = "404";
                string output = JsonConvert.SerializeObject(DTO);
                return(output);
            }
        }
Пример #35
0
        public StatusCodeResult ChangePassword([FromBody] UserInfoDTO data)
        {
            string email = "";

            // get users email from the token sent
            email = SessionController.sm.getEmail(data.authToken);

            // make sure user is authenticated
            if (SessionController.sm.ifTokenValid(data.authToken))
            {
                AccountCreator c = new AccountCreator();

                // check that passwords match and length is 8 or more
                if (data.password.Equals(data.password2) && data.password.Length > 7)
                {
                    // check that old password was correct
                    int status = AccountValidator.compareCredentials(email, data.currentPassword);

                    // if current password was valid, go through with password change
                    if (status == 1)
                    {
                        c.changePassword(data.password, email);
                        return(StatusCode(200));
                    }
                    else
                    {
                        return(StatusCode(400));
                    }
                }
                else
                {
                    return(StatusCode(400));
                }
            }
            else
            {
                return(StatusCode(401));
            }
        }
Пример #36
0
 public override IEnumerable<BusinessRule> Validate()
 {
     AccountValidator validator = new AccountValidator();
     ValidationResult results = validator.Validate(this);
     foreach (var item in results.Errors)
     {
         yield return new BusinessRule(item.PropertyName, item.ErrorMessage);
     }
 }