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);
        }
Ejemplo n.º 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)));
        }
Ejemplo n.º 4
0
 public AuthController(ApplicationContext db, UserService userService, IEnumerable <SocialAuthService> authServices, ConfirmationService confirmationService)
 {
     _db                  = db;
     _userService         = userService;
     _authServices        = authServices;
     _confirmationService = confirmationService;
 }
Ejemplo n.º 5
0
 public AccountController()
 {
     FSservice         = ServiceLocator.GetService <FileSystemService>();
     _pdfService       = ServiceLocator.GetService <PDFServiceSoapClient>();
     _conSrv           = ServiceLocator.GetService <ConfirmationService>();
     _userActionLogSrv = ServiceLocator.GetService <UserActionService>();
 }
Ejemplo n.º 6
0
 public MusicController()
 {
     _mscService   = ServiceLocator.GetService <MusicService>();
     _mailService  = ServiceLocator.GetService <PaskolEmailService>();
     _tgService    = ServiceLocator.GetService <TagService>();
     _cnfrmService = ServiceLocator.GetService <ConfirmationService>();
 }
Ejemplo n.º 7
0
 public ConfirmBaseController()
 {
     purchaseService = ServiceLocator.GetService <PurchaseService>();
     service         = ServiceLocator.GetService <ConfirmationService>();
     MAILService     = ServiceLocator.GetService <PaskolEmailService>();
     musicSrv        = ServiceLocator.GetService <MusicService>();
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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)
 {
 }
Ejemplo n.º 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)));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 14
0
 // 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??
 }
Ejemplo n.º 15
0
 public OrderConfirmationController(
     ConfirmationService confirmationService,
     AddressBookService addressBookService,
     IRecommendationService recommendationService,
     CustomerContextFacade customerContextFacade,
     IOrderGroupTotalsCalculator orderGroupTotalsCalculator)
     : base(confirmationService, addressBookService, customerContextFacade, orderGroupTotalsCalculator)
 {
     _recommendationService = recommendationService;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 18
0
 public OrderConfirmationController(
     ConfirmationService confirmationService,
     AddressBookService addressBookService,
     CustomerContextFacade customerContextFacade,
     IOrderGroupTotalsCalculator orderGroupTotalsCalculator,
     IKlarnaCheckoutService klarnaCheckoutService)
     : base(confirmationService, addressBookService, customerContextFacade, orderGroupTotalsCalculator)
 {
     _klarnaCheckoutService = klarnaCheckoutService;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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));
        }
Ejemplo n.º 22
0
 public WidgetBlockController(ICommerceTrackingService commerceTrackingService,
                              ReferenceConverter referenceConverter,
                              IRequiredClientResourceList requiredClientResource,
                              ICartService cartService,
                              ConfirmationService confirmationService)
 {
     _trackingService        = commerceTrackingService;
     _referenceConverter     = referenceConverter;
     _requiredClientResource = requiredClientResource;
     _cartService            = cartService;
     _confirmationService    = confirmationService;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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());
        }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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"));
        }
Ejemplo n.º 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));
        }