public ConfirmationServiceSetups()
        {
            _userRepoMock             = new RepositoryMock <User>(GetUsersTestData().ToList());
            _userDetailsRepoMock      = new RepositoryMock <UserDetails>(GetUserDetailsTestData().ToList());
            _roleRepoMock             = new RepositoryMock <Role>(GetRolesTestData().ToList());
            _userConfirmationRepoMock = new RepositoryMock <UserConfirmation>(GetUserConfirmationsTestData().ToList());
            _unitOfWorkMock           = new Mock <IUnitOfWork>();
            _unitOfWorkMock.Setup(u => u.Repository <User>()).Returns(_userRepoMock.Repository.Object);
            _unitOfWorkMock.Setup(u => u.Repository <UserDetails>()).Returns(_userDetailsRepoMock.Repository.Object);
            _unitOfWorkMock.Setup(u => u.Repository <Role>()).Returns(_roleRepoMock.Repository.Object);
            _unitOfWorkMock.Setup(u => u.Repository <UserConfirmation>()).Returns(_userConfirmationRepoMock.Repository.Object);
            _unitOfWorkMock.Setup(u => u.SaveChangesAsync()).Verifiable();
            var mockEnvironment = new Mock <IHostingEnvironment>();

            mockEnvironment.SetupAllProperties();
            mockEnvironment.Setup(m => m.ContentRootPath).Returns("");
            mockEnvironment.Setup(m => m.EnvironmentName).Returns("TEST");
            var _emailSettings = Options.Create(new EmailSettings());

            _sendGridMock = new Mock <ISendGridClient>();
            _sendGridMock.SetupAllProperties();
            var response = new Response(System.Net.HttpStatusCode.OK, null, null);

            _sendGridMock.Setup(x => x.SendEmailAsync(It.IsAny <SendGridMessage>(), CancellationToken.None)).Returns(Task.FromResult(response));
            _confirmationService = new ConfirmationService(mockEnvironment.Object, _unitOfWorkMock.Object, _emailSettings, _sendGridMock.Object);
        }
Пример #2
0
        public void TestCrmServiceThrowsError()
        {
            var entityCacheMessageId = Guid.NewGuid();
            var entityCacheId        = Guid.NewGuid();
            var sourceSystemId       = "source system id";
            var serviceResponse      = new IntegrationLayerResponse
            {
                SourceSystemEntityID   = sourceSystemId,
                SourceSystemStatusCode = HttpStatusCode.OK,
                SourceSystemRequest    = "SourceSystemRequest",
                SourceSystemResponse   = "SourceSystemResponse"
            };

            var crmService = A.Fake <ICrmService>();

            A.CallTo(() => crmService.ProcessEntityCacheMessage(entityCacheMessageId, sourceSystemId, Status.Inactive, EntityCacheMessageStatusReason.EndtoEndSuccess, null)).Throws(new Exception("exception"));

            var confirmationService = new ConfirmationService(crmService);
            var response            = confirmationService.ProcessResponse(entityCacheMessageId, serviceResponse);

            A.CallTo(() => crmService.ProcessEntityCacheMessage(entityCacheMessageId, sourceSystemId, Status.Inactive, EntityCacheMessageStatusReason.EndtoEndSuccess, null)).MustHaveHappened();

            Assert.AreEqual(HttpStatusCode.GatewayTimeout, response.StatusCode);
            Assert.AreEqual(Messages.FailedToUpdateEntityCacheMessage, response.Message);
        }
        public async Task <ActionResult> Index(OrderConfirmationPage currentPage, string notificationMessage, int?orderNumber)
        {
            IPurchaseOrder order = null;

            if (PageEditing.PageIsInEditMode)
            {
                order = ConfirmationService.CreateFakePurchaseOrder();
            }
            else if (orderNumber.HasValue)
            {
                order = ConfirmationService.GetOrder(orderNumber.Value);

                if (order != null)
                {
                    await _recommendationService.TrackOrderAsync(HttpContext, order);
                }
            }

            if (order != null && order.CustomerId == CustomerContext.CurrentContactId)
            {
                var viewModel = CreateViewModel(currentPage, order);
                viewModel.NotificationMessage = notificationMessage;

                return(View(viewModel));
            }

            return(Redirect(Url.ContentUrl(ContentReference.StartPage)));
        }
Пример #4
0
 public AuthController(ApplicationContext db, UserService userService, IEnumerable <SocialAuthService> authServices, ConfirmationService confirmationService)
 {
     _db                  = db;
     _userService         = userService;
     _authServices        = authServices;
     _confirmationService = confirmationService;
 }
Пример #5
0
 public AccountController()
 {
     FSservice         = ServiceLocator.GetService <FileSystemService>();
     _pdfService       = ServiceLocator.GetService <PDFServiceSoapClient>();
     _conSrv           = ServiceLocator.GetService <ConfirmationService>();
     _userActionLogSrv = ServiceLocator.GetService <UserActionService>();
 }
Пример #6
0
 public MusicController()
 {
     _mscService   = ServiceLocator.GetService <MusicService>();
     _mailService  = ServiceLocator.GetService <PaskolEmailService>();
     _tgService    = ServiceLocator.GetService <TagService>();
     _cnfrmService = ServiceLocator.GetService <ConfirmationService>();
 }
Пример #7
0
 public ConfirmBaseController()
 {
     purchaseService = ServiceLocator.GetService <PurchaseService>();
     service         = ServiceLocator.GetService <ConfirmationService>();
     MAILService     = ServiceLocator.GetService <PaskolEmailService>();
     musicSrv        = ServiceLocator.GetService <MusicService>();
 }
Пример #8
0
        public void TestIntegrationResponseStatusOkEntityCacheMessageDoesNotExist()
        {
            var entityCacheMessageId = Guid.NewGuid();
            var sourceSystemId       = "source system id";
            var serviceResponse      = new IntegrationLayerResponse
            {
                SourceSystemEntityID   = sourceSystemId,
                SourceSystemStatusCode = HttpStatusCode.OK
            };

            var crmService = A.Fake <ICrmService>();

            A.CallTo(() => crmService.ProcessEntityCacheMessage(entityCacheMessageId, sourceSystemId, Status.Inactive, EntityCacheMessageStatusReason.EndtoEndSuccess, null)).Returns(Guid.Empty);
            A.CallTo(() => crmService.ActivateRelatedPendingEntityCache(Guid.Empty)).DoesNothing();
            A.CallTo(() => crmService.ProcessEntityCache(Guid.Empty, Status.Inactive, EntityCacheStatusReason.Succeeded, true, null)).DoesNothing();

            var confirmationService = new ConfirmationService(crmService);
            var response            = confirmationService.ProcessResponse(entityCacheMessageId, serviceResponse);

            A.CallTo(() => crmService.ProcessEntityCacheMessage(entityCacheMessageId, sourceSystemId, Status.Inactive, EntityCacheMessageStatusReason.EndtoEndSuccess, null)).MustHaveHappened();
            A.CallTo(() => crmService.ActivateRelatedPendingEntityCache(Guid.Empty)).MustNotHaveHappened();
            A.CallTo(() => crmService.ProcessEntityCache(Guid.Empty, Status.Inactive, EntityCacheStatusReason.Succeeded, true, null)).MustNotHaveHappened();

            Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode);
            Assert.AreEqual(string.Format(Messages.MsdCorrelationIdDoesNotExist, entityCacheMessageId), response.Message);
        }
Пример #9
0
 public PurchaseController()
 {
     _permCatSrv = ServiceLocator.GetService <PermissionCategoryService>();
     _mscSrv     = ServiceLocator.GetService <MusicService>();
     _permSrv    = ServiceLocator.GetService <PermissionService>();
     _cnfrmSrv   = ServiceLocator.GetService <ConfirmationService>();
     _prchSrv    = ServiceLocator.GetService <PurchaseService>();
 }
 public OrderConfirmationMailPageController(
     ConfirmationService confirmationService,
     AddressBookService addressBookService,
     CustomerContextFacade customerContextFacade,
     IOrderGroupCalculator orderGroupTotalsCalculator)
     : base(confirmationService, addressBookService, customerContextFacade, orderGroupTotalsCalculator)
 {
 }
Пример #11
0
        public async Task <ActionResult> Index(OrderConfirmationPage currentPage, string notificationMessage, string orderNumber, string trackingNumber)
        {
            int orderId;

            trackingNumber = string.IsNullOrEmpty(trackingNumber) ? orderNumber : trackingNumber;

            IPurchaseOrder order = null;

            if (PageEditing.PageIsInEditMode)
            {
                order = ConfirmationService.CreateFakePurchaseOrder();
            }
            else if (int.TryParse(orderNumber, out orderId))
            {
                order = ConfirmationService.GetOrder(orderId);

                if (order != null)
                {
                    await _recommendationService.TrackOrderAsync(HttpContext, order);
                }
            }
            else if (!string.IsNullOrEmpty(trackingNumber))
            {
                order = ConfirmationService.GetByTrackingNumber(trackingNumber);

                if (order != null)
                {
                    await _recommendationService.TrackOrderAsync(HttpContext, order);
                }
            }

            if (order != null && order.CustomerId == CustomerContext.CurrentContactId)
            {
                var viewModel = CreateViewModel(currentPage, order);
                viewModel.NotificationMessage = notificationMessage;

                var paymentMethod = PaymentManager
                                    .GetPaymentMethodBySystemName(Constants.KlarnaCheckoutSystemKeyword,
                                                                  ContentLanguage.PreferredCulture.Name)
                                    .PaymentMethod.FirstOrDefault();

                if (paymentMethod != null &&
                    order.GetFirstForm().Payments.Any(x => x.PaymentMethodId == paymentMethod.PaymentMethodId &&
                                                      !string.IsNullOrEmpty(order.Properties[Klarna.Common.Constants.KlarnaOrderIdField]?.ToString())))
                {
                    var market      = _marketService.GetMarket(order.MarketId);
                    var klarnaOrder = await _klarnaCheckoutService.GetOrder(
                        order.Properties[Klarna.Common.Constants.KlarnaOrderIdField].ToString(), market).ConfigureAwait(false);

                    viewModel.KlarnaCheckoutHtmlSnippet = klarnaOrder.HtmlSnippet;
                    viewModel.IsKlarnaCheckout          = true;
                }

                return(View(viewModel));
            }

            return(Redirect(Url.ContentUrl(ContentReference.StartPage)));
        }
Пример #12
0
        public void TestEntityCacheMessageIdEmpty()
        {
            var confirmationService = new ConfirmationService(null);

            var response = confirmationService.ProcessResponse(Guid.Empty, null);

            Assert.IsTrue(response.StatusCode == HttpStatusCode.GatewayTimeout);
            Assert.IsTrue(response.Message == Messages.FailedToUpdateEntityCacheMessage);
        }
Пример #13
0
        public void TestCrmServiceIsNull()
        {
            var confirmationService = new ConfirmationService(null);

            var response = confirmationService.ProcessResponse(Guid.NewGuid(), new IntegrationLayerResponse());

            Assert.IsTrue(response.StatusCode == HttpStatusCode.GatewayTimeout);
            Assert.IsTrue(response.Message == Messages.FailedToUpdateEntityCacheMessage);
        }
 // GET: Confirmation
 public ActionResult Index(string clink)
 {
     if (clink != null)
     {
         var conSer = new ConfirmationService();
         conSer.Confirm(clink);
         TempData["error-message"] = "Váš email byl ověřen";
     }
     return(View("Index", "Home"));//TODO: přesměrovat na úvodní stránku a dát to uživateli nějak vědět že je ověřen??
 }
Пример #15
0
 public OrderConfirmationController(
     ConfirmationService confirmationService,
     AddressBookService addressBookService,
     IRecommendationService recommendationService,
     CustomerContextFacade customerContextFacade,
     IOrderGroupTotalsCalculator orderGroupTotalsCalculator)
     : base(confirmationService, addressBookService, customerContextFacade, orderGroupTotalsCalculator)
 {
     _recommendationService = recommendationService;
 }
Пример #16
0
 public OrderConfirmationMailController(ConfirmationService confirmationService,
                                        AddressBookService addressBookService,
                                        CustomerService customerService,
                                        IOrderGroupCalculator orderGroupCalculator)
 {
     _confirmationService  = confirmationService;
     _addressBookService   = addressBookService;
     _customerService      = customerService;
     _orderGroupCalculator = orderGroupCalculator;
 }
 public OrderConfirmationController(
     ICampaignService campaignService,
     ConfirmationService confirmationService,
     IAddressBookService addressBookService,
     IOrderGroupCalculator orderGroupCalculator,
     UrlResolver urlResolver, ICustomerService customerService) :
     base(confirmationService, addressBookService, orderGroupCalculator, urlResolver, customerService)
 {
     _campaignService = campaignService;
 }
Пример #18
0
 public OrderConfirmationController(
     ConfirmationService confirmationService,
     AddressBookService addressBookService,
     CustomerContextFacade customerContextFacade,
     IOrderGroupTotalsCalculator orderGroupTotalsCalculator,
     IKlarnaCheckoutService klarnaCheckoutService)
     : base(confirmationService, addressBookService, customerContextFacade, orderGroupTotalsCalculator)
 {
     _klarnaCheckoutService = klarnaCheckoutService;
 }
Пример #19
0
        public static string ConfirmAction(this UrlHelper helper, string message, string actionUrl)
        {
            var confirmId = ConfirmationService.GetId(
                new ConfirmationData
            {
                Message   = message,
                ActionUrl = actionUrl
            });

            return(helper.Action("action", "confirmation", new { id = confirmId }));
        }
 protected OrderConfirmationControllerBase(
     ConfirmationService confirmationService,
     AddressBookService addressBookService,
     CustomerContextFacade customerContextFacade,
     IOrderGroupTotalsCalculator orderGroupTotalsCalculator)
 {
     ConfirmationService         = confirmationService;
     _addressBookService         = addressBookService;
     CustomerContext             = customerContextFacade;
     _orderGroupTotalsCalculator = orderGroupTotalsCalculator;
 }
Пример #21
0
        public static MvcHtmlString ConfirmActionLink(this HtmlHelper helper, string linkText, string message, string actionUrl, object htmlAttributes = null)
        {
            var confirmId = ConfirmationService.GetId(
                new ConfirmationData
            {
                Message   = message,
                ActionUrl = actionUrl
            });

            return(helper.ActionLink(linkText, "action", "confirmation", new { id = confirmId }, htmlAttributes));
        }
Пример #22
0
 public WidgetBlockController(ICommerceTrackingService commerceTrackingService,
                              ReferenceConverter referenceConverter,
                              IRequiredClientResourceList requiredClientResource,
                              ICartService cartService,
                              ConfirmationService confirmationService)
 {
     _trackingService        = commerceTrackingService;
     _referenceConverter     = referenceConverter;
     _requiredClientResource = requiredClientResource;
     _cartService            = cartService;
     _confirmationService    = confirmationService;
 }
Пример #23
0
 protected OrderConfirmationControllerBase(ConfirmationService confirmationService,
                                           IAddressBookService addressBookService,
                                           IOrderGroupCalculator orderGroupTotalsCalculator,
                                           UrlResolver urlResolver,
                                           ICustomerService customerService)
 {
     _confirmationService  = confirmationService;
     _addressBookService   = addressBookService;
     _orderGroupCalculator = orderGroupTotalsCalculator;
     _urlResolver          = urlResolver;
     _customerService      = customerService;
 }
 protected OrderConfirmationControllerBase(
     ConfirmationService confirmationService,
     AddressBookService addressBookService,
     CustomerContextFacade customerContextFacade,
     IOrderGroupCalculator orderGroupCalculator,
     IMarketService marketService)
 {
     ConfirmationService   = confirmationService;
     _addressBookService   = addressBookService;
     CustomerContext       = customerContextFacade;
     _orderGroupCalculator = orderGroupCalculator;
     _marketService        = marketService;
 }
Пример #25
0
        public ActionResult Yes(ConfirmationActionViewModel model)
        {
            if (!model.HttpPost)
            {
                return(Redirect(model.YesUrl));
            }

            ConfirmationData data = ConfirmationService.GetData(model.Id);

            RouteData route = RoutesHelper.GetRouteDataByUrl("/" + model.YesUrl);

            //var controllerDescriptor = new ReflectedControllerDescriptor(GetType());
            string controllerName = (String)route.Values["controller"];
            string actionName     = (String)route.Values["action"];
            //string values = RouteData.GetRequiredString("id");

            //IControllerActivator
            DefaultControllerFactory d = new DefaultControllerFactory();

            IController controller = d.CreateController(HttpContext.Request.RequestContext, controllerName);

            ControllerDescriptor controllerDescriptor = new ReflectedControllerDescriptor(controller.GetType());
            //d.ReleaseController(controller);

            ActionDescriptor actionDescriptor = controllerDescriptor.FindAction(ControllerContext, actionName);

            RequestContext requestContext = new RequestContext(new RoutesHelper.RewritedHttpContextBase("/" + model.YesUrl), route);

            requestContext.HttpContext.Request.Form.Add((NameValueCollection)data.PostData);

            ControllerContext            ctx         = new ControllerContext(requestContext, (ControllerBase)controller);
            IDictionary <string, object> parameters2 = GetParameterValues(ctx, actionDescriptor);
            IDictionary <string, object> parameters  = new Dictionary <string, object>();

            ControllerContext.HttpContext.Response.Clear();
            NameValueCollection nameValueCollection = data.PostData as NameValueCollection;

            //nameValueCollection.
            actionDescriptor.Execute(ControllerContext, (IDictionary <string, object>)data.PostData);

            //var viewResult = new ViewResult
            //{
            //    ViewName = "",
            //    MasterName = "",
            //    ViewData = new ViewDataDictionary(data.PostData),
            //    TempData = null
            //};

            //return viewResult;
            return(new EmptyResult());
        }
Пример #26
0
 public OrderConfirmationController(
     ConfirmationService confirmationService,
     AddressBookService addressBookService,
     CustomerContextFacade customerContextFacade,
     IOrderGroupCalculator orderGroupCalculator,
     IMarketService marketService,
     IRecommendationService recommendationService,
     IKlarnaCheckoutService klarnaCheckoutService)
     : base(confirmationService, addressBookService, customerContextFacade, orderGroupCalculator, marketService)
 {
     _marketService         = marketService;
     _recommendationService = recommendationService;
     _klarnaCheckoutService = klarnaCheckoutService;
 }
Пример #27
0
 public OrderHistoryController(IAddressBookService addressBookService,
                               IOrderRepository orderRepository,
                               ConfirmationService confirmationService,
                               ICartService cartService,
                               IOrderGroupCalculator orderGroupCalculator,
                               IContentLoader contentLoader,
                               UrlResolver urlResolver, IOrderGroupFactory orderGroupFactory, ICustomerService customerService) :
     base(confirmationService, addressBookService, orderGroupCalculator, urlResolver, customerService)
 {
     _addressBookService = addressBookService;
     _orderRepository    = orderRepository;
     _contentLoader      = contentLoader;
     _cartService        = cartService;
     _orderGroupFactory  = orderGroupFactory;
 }
Пример #28
0
        public void Setup()
        {
            _userRepoStub             = new Mock <IUserRepository>();
            _mailerStub               = new Mock <IMailer>();
            _validationRequesRepoStub = new Mock <IValidationRequestsRepository>();
            _eventSinkManagerStub     = new Mock <IEventSink>();
            _eventBus = new Mock <IEventBus>();

            _confirmationService = new ConfirmationService(
                _userRepoStub.Object,
                _mailerStub.Object,
                _validationRequesRepoStub.Object,
                _eventSinkManagerStub.Object,
                new ConfirmationSettings(new Uri("http://lod-misis.ru/frontend")),
                _eventBus.Object);
        }
Пример #29
0
        public ActionResult SignUp(string email, string pwd)
        {
            if (ModelState.IsValid)
            {
                var user = new User()
                {
                    Email       = email,
                    IsConfirmed = false
                };
                var confirmationService = new ConfirmationService();
                user.ConfirmationLink = confirmationService.GetUniqeConfirmationLink(HttpContext.Request.Url.Authority);
                user.Password         = PasswordHashing.HashString(pwd);
                using (var db = new Database())
                {
                    var superiorLink = Session["link"];
                    if (superiorLink != null)
                    {
                        user.SupperiorId = db.Users.FirstOrDefault(x => x.Link == superiorLink).UserId;
                    }
                    if (db.Users.Any(x => x.Email == email))
                    {
                        TempData["error-message"] = "Uživatel s tímto emailem již existuje";
                        return(RedirectToAction("Index", "Home"));
                    }

                    user.Link = Generators.GetRandomUniqueLink(7);

                    using (var dbContextTransaction = db.Database.BeginTransaction())
                    {
                        try
                        {
                            db.Users.Add(user);
                            db.SaveChanges();

                            confirmationService.SendConfirmationEmail(user.Email, user.ConfirmationLink);
                            dbContextTransaction.Commit();
                        }
                        catch (Exception)
                        {
                            dbContextTransaction.Rollback();
                        }
                    }
                }
            }

            return(RedirectToAction("Index", "Home"));
        }
Пример #30
0
        public ActionResult Action(Guid id, object[] args)
        {
            ConfirmationData data = ConfirmationService.GetData(id);

            ConfirmationService.SetPostData(id, Request.Form);

            ConfirmationActionViewModel model = new ConfirmationActionViewModel
            {
                Id       = id,
                Message  = data.Message,
                NoUrl    = Request.UrlReferrer.PathAndQuery,
                YesUrl   = data.ActionUrl,
                HttpPost = true
            };

            return(View(model));
        }