Exemplo n.º 1
0
        public async Task <IActionResult> List(string searchString, int payNumber = 1, int paySize = 5, int cardNumber = 1, int cardSize = 5)
        {
            var userId = HttpContext.User.Identity.Name;
            PaymentsViewModel PaymentsModel = new PaymentsViewModel();

            try
            {
                PaymentsModel.CreditCards = await _cacheService.GetOrCreateCachedResponse <CreditCard>(CacheKeys.CreditCard + AuthUserId, () => _apiService.GetAllUserData <CreditCard>(Int32.Parse(AuthUserId)));
            }
            catch (HttpRequestException)
            {
                PaymentsModel.CreditCards = Enumerable.Empty <CreditCard>();
            }
            PaymentsModel.CreditCards = PaymentsModel.CreditCards ?? Enumerable.Empty <CreditCard>();

            try
            {
                PaymentsModel.PaypalAccounts = await _cacheService.GetOrCreateCachedResponse <PaypalAccount>(CacheKeys.PaypalAccount + AuthUserId, () => _apiService.GetAllUserData <PaypalAccount>(Int32.Parse(AuthUserId)));
            }
            catch (HttpRequestException)
            {
                PaymentsModel.PaypalAccounts = Enumerable.Empty <PaypalAccount>();
            }
            PaymentsModel.PaypalAccounts = PaymentsModel.PaypalAccounts ?? Enumerable.Empty <PaypalAccount>();



            if (!String.IsNullOrEmpty(searchString))
            {
                //  PaymentsModel.CreditCards = ViewHelper.FilterResult<CreditCard>(PaymentsModel.CreditCards, searchString);
            }



            Dictionary <int, string> encryptedIdsPay = new Dictionary <int, string>();

            foreach (var x in PaymentsModel.PaypalAccounts)
            {
                encryptedIdsPay.Add(x.Id, dataProtectionHelper.Encrypt(x.Id.ToString(), "QueryStringsEncryptions"));
            }
            ViewBag.EncryptedIdsPay = encryptedIdsPay;

            Dictionary <int, string> encryptedIdsCard = new Dictionary <int, string>();

            foreach (var x in PaymentsModel.CreditCards)
            {
                encryptedIdsCard.Add(x.Id, dataProtectionHelper.Encrypt(x.Id.ToString(), "QueryStringsEncryptions"));
            }
            ViewBag.EncryptedIdsCard = encryptedIdsCard;


            return(View("Views/Wallet/UltraPay.cshtml", PaymentsModel));
        }
        public async Task <IActionResult> List(string searchString, int pageNumber = 1, int pageSize = 5)
        {
            IEnumerable <LoginData> loginDatas;

            try
            {
                loginDatas = await _cacheService.GetOrCreateCachedResponse <LoginData>(CacheKeys.LoginData + AuthUserId, () => _apiService.GetAllUserData <LoginData>(Int32.Parse(AuthUserId)));
            }
            catch (HttpRequestException)
            {
                loginDatas = Enumerable.Empty <LoginData>();
            }
            loginDatas = loginDatas ?? Enumerable.Empty <LoginData>();



            if (!String.IsNullOrEmpty(searchString))
            {
                loginDatas = ViewHelper.FilterResult <LoginData>(loginDatas, searchString);
            }



            Dictionary <int, string> encryptedIds = new Dictionary <int, string>();

            foreach (var x in loginDatas)
            {
                encryptedIds.Add(x.Id, dataProtectionHelper.Encrypt(x.Id.ToString(), _config["QueryStringsEncryptions"]));
            }
            ViewBag.EncryptedIds = encryptedIds;

            return(View("Views/Wallet/ListItem.cshtml", ViewHelper.PaginateResult <LoginData>(loginDatas, pageSize, pageNumber)));
        }
        public void CreateAndSendAuthorizationToken(int authUserId, string userPassword)
        {
            User   authUser = GetById(authUserId);
            string token    = authUser.Id.ToString() + "|" + authUser.Email + "|" + DateTime.UtcNow.AddMinutes(10).ToString();

            token = dataProtectionHelper.Encrypt(token, userPassword);
            string url = QueryHelpers.AddQueryString($"{_config["WebDomain"]}auth/deleteaccount2step", "token", token);

            _emailSender.SendEmailAsync(new Message(new string[] { authUser.Email },
                                                    "Link do usunięcia konta. Pass Manager App", "Link do usunięcia konta w serwisie Pass Manager App : " + url + " dla uzytkownika: "
                                                    + authUser.Email + " Podany link będzie aktywny przez 10 minut."));
        }
        public async Task <IActionResult> Note()
        {
            IEnumerable <Note> userNotes;

            try
            {
                userNotes = await _cacheService.GetOrCreateCachedResponse <Note>(CacheKeys.Note + AuthUserId, () => _apiService.GetAllUserData <Note>(Int32.Parse(AuthUserId)));
            }
            catch (HttpRequestException)
            {
                userNotes = Enumerable.Empty <Note>();
            }
            userNotes = userNotes ?? Enumerable.Empty <Note>();

            Dictionary <int, string> encryptedIds = new Dictionary <int, string>();

            foreach (var x in userNotes)
            {
                encryptedIds.Add(x.Id, dataProtectionHelper.Encrypt(x.Id.ToString(), "QueryStringsEncryptions"));
            }
            ViewBag.EncryptedIds = encryptedIds;
            return(View("Views/Wallet/ListNote.cshtml", userNotes));
        }
        public async Task <IActionResult> Index(string searchString, int payNumber = 1, int paySize = 5, int cardNumber = 1, int cardSize = 5)
        {
            var userId = HttpContext.User.Identity.Name;
            PwnedExpiredViewModel pwnedExpiredModel = new PwnedExpiredViewModel();

            try
            {
                pwnedExpiredModel.LoginDatasBreached = await _cacheService.GetOrCreateCachedResponse <LoginData>(CacheKeys.LoginDataBreached + AuthUserId, () => _apiService.GetAllUserData <LoginData>(Int32.Parse(AuthUserId), compromised: 1));

                pwnedExpiredModel.LoginDatasExpired = await _cacheService.GetOrCreateCachedResponse <LoginData>(CacheKeys.LoginDataExpired + AuthUserId, () => _apiService.GetAllUserData <LoginData>(Int32.Parse(AuthUserId), expired: 1));
            }
            catch (HttpRequestException)
            {
                pwnedExpiredModel.LoginDatasBreached = Enumerable.Empty <LoginData>();
                pwnedExpiredModel.LoginDatasExpired  = Enumerable.Empty <LoginData>();
            }
            pwnedExpiredModel.LoginDatasBreached = pwnedExpiredModel.LoginDatasBreached ?? Enumerable.Empty <LoginData>();
            pwnedExpiredModel.LoginDatasExpired  = pwnedExpiredModel.LoginDatasExpired ?? Enumerable.Empty <LoginData>();

            try
            {
                pwnedExpiredModel.PaypalAccountsBreached = await _cacheService.GetOrCreateCachedResponse <PaypalAccount>(CacheKeys.PaypalAccountBreached + AuthUserId, () => _apiService.GetAllUserData <PaypalAccount>(Int32.Parse(AuthUserId), compromised: 1));

                pwnedExpiredModel.PaypalAccountsExpired = await _cacheService.GetOrCreateCachedResponse <PaypalAccount>(CacheKeys.PaypalAccountExpired + AuthUserId, () => _apiService.GetAllUserData <PaypalAccount>(Int32.Parse(AuthUserId), expired: 1));
            }
            catch (HttpRequestException)
            {
                pwnedExpiredModel.PaypalAccountsBreached = Enumerable.Empty <PaypalAccount>();
                pwnedExpiredModel.PaypalAccountsExpired  = Enumerable.Empty <PaypalAccount>();
            }
            pwnedExpiredModel.PaypalAccountsBreached = pwnedExpiredModel.PaypalAccountsBreached ?? Enumerable.Empty <PaypalAccount>();
            pwnedExpiredModel.PaypalAccountsExpired  = pwnedExpiredModel.PaypalAccountsExpired ?? Enumerable.Empty <PaypalAccount>();



            if (!String.IsNullOrEmpty(searchString))
            {
                //  PaymentsModel.CreditCards = ViewHelper.FilterResult<CreditCard>(PaymentsModel.CreditCards, searchString);
            }



            Dictionary <int, string> encryptedIdsLogBreached = new Dictionary <int, string>();

            foreach (var x in pwnedExpiredModel.LoginDatasBreached)
            {
                encryptedIdsLogBreached.Add(x.Id, dataProtectionHelper.Encrypt(x.Id.ToString(), "QueryStringsEncryptions"));
            }
            ViewBag.encryptedIdsLogBreached = encryptedIdsLogBreached;
            Dictionary <int, string> encryptedIdsLogExpired = new Dictionary <int, string>();

            foreach (var x in pwnedExpiredModel.LoginDatasExpired)
            {
                encryptedIdsLogExpired.Add(x.Id, dataProtectionHelper.Encrypt(x.Id.ToString(), "QueryStringsEncryptions"));
            }
            ViewBag.encryptedIdsLogExpired = encryptedIdsLogExpired;

            Dictionary <int, string> encryptedIdsPayBreached = new Dictionary <int, string>();

            foreach (var x in pwnedExpiredModel.PaypalAccountsBreached)
            {
                encryptedIdsPayBreached.Add(x.Id, dataProtectionHelper.Encrypt(x.Id.ToString(), "QueryStringsEncryptions"));
            }
            ViewBag.encryptedIdsPayBreached = encryptedIdsPayBreached;
            Dictionary <int, string> encryptedIdsPayExpired = new Dictionary <int, string>();

            foreach (var x in pwnedExpiredModel.PaypalAccountsExpired)
            {
                encryptedIdsPayExpired.Add(x.Id, dataProtectionHelper.Encrypt(x.Id.ToString(), "QueryStringsEncryptions"));
            }
            ViewBag.encryptedIdsPayExpired = encryptedIdsPayExpired;


            return(View("Views/Wallet/ListPwnedExpired.cshtml", pwnedExpiredModel));
        }