Пример #1
0
        public void EmailAvailable()
        {
            var AccountMock = new Mock <IAccountRepository>();

            AccountMock.Setup(m => m.CheckEmailAvailable(It.IsAny <string>())).Returns(true);
            AccountMock.Setup(m => m.ValidateAccount(It.IsAny <User>())).Returns(new List <string>());

            RegistrationInteractor interactor = new RegistrationInteractor(AccountMock.Object);

            interactor.Handle(request);
            AccountMock.Verify(m => m.CreateAcount(It.IsAny <User>(), It.IsAny <string>()), Times.Once);
        }
        public ActionResult RegisterAcount(RegistrationRequestViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View("Index"));
            }
            RegistrationInteractor registrationRequestInteractor = new RegistrationInteractor(_accountRepository);
            var requestMessage  = new RegistrationRequest(model.Email, model.Password);
            var responseMessage = registrationRequestInteractor.Handle(requestMessage);

            var presenter = new RegistrationPresenter();

            var viewModel = presenter.Handle(responseMessage);


            return(PartialView("RegistrationNotification", viewModel));
        }
        public async Task <IActionResult> CreateAcount([FromBody] RegistrationRequestViewModel model)
        {
            RegistrationInteractor registrationRequestInteractor = new RegistrationInteractor(_accountRepository);
            var requestMessage  = new RegistrationRequestMessage(model.Email, model.Password, model.FirstName, model.LastName);
            var responseMessage = await registrationRequestInteractor.Handle(requestMessage);

            var presenter = new RegistrationResponsePresenter();

            var viewModel = presenter.Handle(responseMessage);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            return(new OkObjectResult(viewModel));
        }