Ejemplo n.º 1
0
 public CustomerController(UnitOfWork unitOfWork, IEmailGateway emailGateway)
 {
     _unitOfWork         = unitOfWork;
     _customerRepository = new CustomerRepository(unitOfWork);
     _industryRepository = new IndustryRepository(unitOfWork);
     _emailGateway       = emailGateway;
 }
        public UsersModule(IUsers users, IPasswordGenerator passwordGenerator,
            IHashing hashing, IEmailGateway emailGateway, IEventLog eventLog)
            : base("/User")
        {
            this.users = users;
            this.passwordGenerator = passwordGenerator;
            this.hashing = hashing;
            this.emailGateway = emailGateway;
            this.eventLog = eventLog;

            Post["/"] = x =>
                            {
                                var email = Request.Query.email.ToString();

                                if (!string.IsNullOrEmpty(email))
                                {
                                    var fromDb = this.users.Get(email);
                                    if (fromDb != null)
                                        return Response.AsJson(new[] {fromDb});

                                    var password = this.users.Create(email);
                                    return Response.AsJson(new[] {new {password}});
                                }
                                return Response.AsJson(Enumerable.Empty<string>());
                            };

            Get["/PasswordReset"] = x =>
                                        {
                                            return View["passwordreset", new Result  { Success = false }];
                                        };

            Post["/PasswordReset"] = x =>
                                         {
                                             bool result = false;
                                             var input = this.Bind<PasswordResetBody>();
                                             if(!string.IsNullOrWhiteSpace(input.email))
                                             {
                                                 var user = this.users.Get(input.email);
                                                 if(user!= null)
                                                 {
                                                     var password = this.passwordGenerator.Generate();
                                                     var hashedPassword = this.hashing.Hash(password);
                                                     this.users.ChangePassword(user.Id, hashedPassword);
                                                     this.emailGateway.SendNewPasswordEmail(user.Email, password);
                                                     result = true;

                                                     this.eventLog.LogEvent(new Event()
                                                                                {
                                                                                    AuthorId = user.Id,
                                                                                    BarCodeId = null,
                                                                                    EventName = "CHANGEPASSWORD",
                                                                                    Ip = this.Request.Headers["X-Forwarded-For"].FirstOrDefault()
                                                                                });
                                                 }
                                             }

                                             return View["passwordreset", new Result { Success = result }];
                                         };
        }
 public void SetUp()
 {
     _paymentProvider = Substitute.For <IPaymentProvider>();
     _emailGateway    = Substitute.For <IEmailGateway>();
     _transactionRepo = Substitute.For <TransactionRepo>();
     _paymentService  = new PaymentService(_paymentProvider, _emailGateway, _transactionRepo);
     _customerId      = "Cust-2345";
 }
Ejemplo n.º 4
0
 public UserService(UserManager <ApplicationUser> userManager,
                    IEmailGateway emailGateway,
                    ILogger <UserService> logger)
 {
     _userManager  = userManager;
     _emailGateway = emailGateway;
     _logger       = logger;
 }
Ejemplo n.º 5
0
 public CustomerController(
     UnitOfWork unitOfWork,
     IEmailGateway emailGateway)
     : base(unitOfWork)
 {
     customerRepository = new CustomerRepository(unitOfWork);
     this.emailGateway  = emailGateway;
 }
Ejemplo n.º 6
0
 public HospitalizationsController(
     IHospitalizationGateway hospitalizationGateway,
     IInteractionsGateway interactionsGateway,
     ILoginGateway loginGateway,
     IEmailGateway emailGateway)
 {
     this.hospitalizationGateway = hospitalizationGateway;
     this.interactionsGateway    = interactionsGateway;
     this.loginGateway           = loginGateway;
     this.emailGateway           = emailGateway;
 }
Ejemplo n.º 7
0
        public void ShouldSendEmailToGateway_AutoRhino()
        {
            // arrange
            var fixture = new Fixture();

            // add auto mocking support for Rhino Mocks
            fixture.Customize(new AutoRhinoMockCustomization());

            IEmailGateway mockGateway = MockRepository.GenerateStub <IEmailGateway>();

            fixture.Inject(mockGateway);

            var sut = fixture.Create <EmailMessageBuffer>();

            sut.Add(fixture.Create <EmailMessage>());


            // act
            sut.SendAll();


            // assert
            mockGateway.AssertWasCalled(x => x.Send(Arg <EmailMessage> .Is.NotNull));
        }
Ejemplo n.º 8
0
 public Controller(IEmailGateway emailGateway)
 {
     _emailGateway = emailGateway;
 }
 public CreateAccountEndpoint(IEmailGateway gateway)
 {
     _gateway = gateway;
 }
 public EmailMessageSendBuffer(IEmailGateway emailGateway)
 {
     EmailGateway = emailGateway;
 }
Ejemplo n.º 11
0
        public UsersModule(IUsers users, IPasswordGenerator passwordGenerator,
                           IHashing hashing, IEmailGateway emailGateway, IEventLog eventLog) : base("/User")
        {
            this.users             = users;
            this.passwordGenerator = passwordGenerator;
            this.hashing           = hashing;
            this.emailGateway      = emailGateway;
            this.eventLog          = eventLog;

            Post["/"] = x =>
            {
                var email = Request.Query.email.ToString();

                if (!string.IsNullOrEmpty(email))
                {
                    var fromDb = this.users.Get(email);
                    if (fromDb != null)
                    {
                        return(Response.AsJson(new[] { fromDb }));
                    }

                    var password = this.users.Create(email);
                    return(Response.AsJson(new[] { new { password } }));
                }
                return(Response.AsJson(Enumerable.Empty <string>()));
            };

            Get["/PasswordReset"] = x =>
            {
                return(View["passwordreset", new Result  {
                                Success = false
                            }]);
            };

            Post["/PasswordReset"] = x =>
            {
                bool result = false;
                var  input  = this.Bind <PasswordResetBody>();
                if (!string.IsNullOrWhiteSpace(input.email))
                {
                    var user = this.users.Get(input.email);
                    if (user != null)
                    {
                        var password       = this.passwordGenerator.Generate();
                        var hashedPassword = this.hashing.Hash(password);
                        this.users.ChangePassword(user.Id, hashedPassword);
                        this.emailGateway.SendNewPasswordEmail(user.Email, password);
                        result = true;

                        this.eventLog.LogEvent(new Event()
                        {
                            AuthorId  = user.Id,
                            BarCodeId = null,
                            EventName = "CHANGEPASSWORD",
                            Ip        = this.Request.Headers["X-Forwarded-For"].FirstOrDefault()
                        });
                    }
                }

                return(View["passwordreset", new Result {
                                Success = result
                            }]);
            };
        }
Ejemplo n.º 12
0
 public ItemAppService(IItemRepositorio itemRepositorio,
                       IEmailGateway emailGateway)
 {
     _itemRepositorio = itemRepositorio;
     _emailGateway    = emailGateway;
 }
Ejemplo n.º 13
0
 public EmailMessageBuffer(IEmailGateway emailGateway)
 {
     EmailGateway = emailGateway;
     Emails       = new Queue <EmailMessage>();
 }
Ejemplo n.º 14
0
 public Transfer(IEmailGateway emailGateway)
 {
     _emailGateway = emailGateway;
 }
 public PaymentService(IPaymentProvider paymentProvider, IEmailGateway emailGateway, TransactionRepo transactionRepo)
 {
     _paymentProvider = paymentProvider;
     _emailGateway    = emailGateway;
     _transactionRepo = transactionRepo;
 }
Ejemplo n.º 16
0
        public CustomerController(IEmailGateway emailGateway)

        {
            _customerRepository = new CustomerRepository();
            _emailGateway       = emailGateway;
        }
 public EmailMessageBuffer(IEmailGateway emailGateway)
 {
     _emailGateway = emailGateway;
     _emails       = new List <EmailMessage>();
 }
Ejemplo n.º 18
0
 public SendEmailController(IEmailGateway emailGateway)
 {
     this.emailGateway = emailGateway;
 }
Ejemplo n.º 19
0
 public EmailMessageBuffer(IEmailGateway emailGateway)
 {
     _emailGateway = emailGateway;
 }
 public EmailMessageBuffer_AutoMockMoq(IEmailGateway emailGateWay)
 {
     _emailGateWay = emailGateWay;
 }
Ejemplo n.º 21
0
 public EmailMessageBuffer(IEmailGateway emailGateway, string someString)
 {
     _emailGateway = emailGateway;
 }