예제 #1
0
        public ExternalClientEN RegisterExternalClient(int pCountryID, string pName, string pAlias, string pDescription, string pPassword, ref string oApiKey)
        {
            ExternalClientEN client = new ExternalClientEN();
            int externalClientID    = 0;
            var now = DateTime.Now;

            try
            {
                client.Active           = true;
                client.Alias            = pAlias;
                client.AssignedPassword = pPassword;
                client.CountryID        = pCountryID;
                client.Description      = pDescription;
                client.GUID             = Guid.NewGuid().ToString().ToUpper();
                client.Name             = pName;
                client.RegDate          = now.Date;

                externalClientID = clientDAL.InsertExternalClient(client);

                if (externalClientID > 0)
                {
                    oApiKey = jwt.encodeClientKey(client);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException);
                EventViewerLoggerBL.LogError("RegisterExternalClient: " + ex.Message);
            }

            return(client);
        }
예제 #2
0
        public bool InsertPurchase(PurchaseEN pPurchase, PersonEN pPerson, string pDepositor, string pBankReference, string pDepositDate)
        {
            bool result = false;

            try
            {
                DateTime date        = Convert.ToDateTime(pDepositDate);
                var      bank        = bankDAL.GetBanks(pPerson.CountryID).Where(b => b.BankID == pPurchase.BankID).FirstOrDefault();
                string   amount      = Convert.ToString(pPurchase.Amount);
                string   fullName    = pPerson.Firstname + " " + pPerson.Lastname;
                string   depositDate = date.ToString("dd-MMM-yyyy", CultureInfo.CreateSpecificCulture("es-MX")).ToUpper();

                result = purchaseDAL.InsertPurchase(pPerson.PersonID, pPurchase.BankID, pPurchase.Amount, pPerson.CountryID, pDepositor, pBankReference, date);

                if (result)
                {
                    emailSender.EmailTransferConfirmationReceived(pPerson.Email, pDepositor, pBankReference, bank.BankName, amount, fullName, depositDate);
                }
            }
            catch (Exception ex)
            {
                result = false;
                Console.WriteLine(ex.InnerException);
                EventViewerLoggerBL.LogError("PurchaseBL " + ex.Message);
            }

            return(result);
        }
예제 #3
0
        public async Task <List <NotificationResultEN> > SendNotification(CampaignEN pCampaign)
        {
            List <NotificationResultEN> camapignResult = new List <NotificationResultEN>();

            try
            {
                int resultInsert = campaignDAL.InsertCampaign(pCampaign);
                if (resultInsert > 0)
                {
                    bool inserted = campaignDAL.InsertUsersNotifications(pCampaign.CountryISO2Code, resultInsert);
                    if (inserted)
                    {
                        //Send notification
                        camapignResult = await handler.HandleContent(pCampaign);
                    }
                }
            }
            catch (Exception ex)
            {
                camapignResult = null;
                Console.WriteLine(ex.InnerException);
                EventViewerLoggerBL.LogError("CampaignBL " + ex.Message);
            }

            return(camapignResult);
        }
예제 #4
0
        public ConsumerEN AuthenticateConsumer(string pToken)
        {
            ConsumerEN consumer = null;

            try
            {
                AuthConsumerEN authKey = consumerDAL.GetConsumerAuthByToken(pToken);

                if (authKey != null)
                {
                    string profileID = jwt.decodeFacebookID(authKey.ConsumerAuthKey);
                    consumer = consumerDAL.GetConsumerByProfileID(profileID);

                    if (consumer != null)
                    {
                        consumer.IsValidKey = true;
                    }
                }
            }
            catch (Exception ex)
            {
                consumer = null;
                Console.WriteLine(ex.InnerException);
                EventViewerLoggerBL.LogError(ex.Message);
            }

            return(consumer);
        }
예제 #5
0
        public string AssociateFacebook(FacebookEN pFacebookProfile)
        {
            string result = "";

            try
            {
                pFacebookProfile.RegDate = DateTime.Now;

                var existsProfile = facebookDAL.GetFacebookProfile(pFacebookProfile.PersonID);

                if (existsProfile != null)
                {
                    pFacebookProfile.Id = existsProfile.Id;
                    result = (facebookDAL.UpdateFacebookProfile(pFacebookProfile) > 0) ? "updated" : "error";
                }
                else
                {
                    result = (facebookDAL.InsertFacebookProfile(pFacebookProfile) > 0) ? "inserted" : "error";
                }
            }
            catch (Exception ex)
            {
                result = "error";
                Console.WriteLine(ex.InnerException);
                EventViewerLoggerBL.LogError(ex.Message);
            }

            return(result);
        }
예제 #6
0
        public ConsumerEN UpdateConsumerProfile(string pPhone, int pCountryID, string pDeviceID, string pURL, string pEmail, string pProfileID, string pUserID, string pFirstName, string pMiddleName, string pLastName, string pConsumerAuth)
        {
            ConsumerEN consumerToUpdate = new ConsumerEN();
            ConsumerEN bringConsumer    = new ConsumerEN();

            try
            {
                consumerToUpdate = consumerDAL.UpdateConsumerProfile(pPhone, pCountryID, pDeviceID, pURL, pEmail, pProfileID, pUserID, pFirstName, pMiddleName, pLastName);

                bringConsumer = consumerDAL.GetConsumerByProfileID(pProfileID);

                if (bringConsumer != null)
                {
                    //var ConsumerUpdated = registerConsumerDAL.GetConsumerByProfileID(pProfileID);
                    ConsumerEN ConsumerUpdated = consumerDAL.GetConsumerByProfileID(pProfileID);

                    var Token = consumerDAL.GetAuthConsumer(bringConsumer.ConsumerID);

                    bringConsumer.ConsumerAuthKey = Token.ConsumerAuthKey;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException);
                EventViewerLoggerBL.LogError(ex.Message);
            }

            return(bringConsumer);
        }
예제 #7
0
        public List <SaleEN> GetIntervalPersonSaleHistory(PersonEN pPerson, string pInterval)
        {
            List <SaleEN> salesHistory = new List <SaleEN>();

            try
            {
                switch (pInterval)
                {
                case "today":
                    salesHistory = saleDAL.GetPersonTodaySalesHistory(pPerson.PersonID, AssignTimeZone(pPerson.CountryID));
                    break;

                case "yesterday":
                    salesHistory = saleDAL.GetPersonYesterdaySalesHistory(pPerson.PersonID, AssignTimeZone(pPerson.CountryID));
                    break;

                case "week":
                    salesHistory = saleDAL.GetPersonIntervalSalesHistory(pPerson.PersonID, AssignTimeZone(pPerson.CountryID), Constants.Week);
                    break;

                default:
                    salesHistory = saleDAL.GetPersonIntervalSalesHistory(pPerson.PersonID, AssignTimeZone(pPerson.CountryID), Constants.Week);
                    break;
                }
            }
            catch (Exception ex)
            {
                salesHistory = null;
                Console.WriteLine(ex.InnerException);
                EventViewerLoggerBL.LogError(ex.Message);
            }

            return(salesHistory);
        }
예제 #8
0
        public List <OperatorEN> GetOperatorProducts(int pCountryID)
        {
            List <OperatorEN> operatorsList = new List <OperatorEN>();

            try
            {
                operatorsList = operatorDAL.GetOperatorsYCR(pCountryID);

                var products = productDAL.GetProductsByCountryID(pCountryID);

                foreach (var ope in operatorsList)
                {
                    ope.Products = new List <ProductEN>();

                    var operatorProducts = products.Where(p => p.OperatorID == ope.OperatorID).ToList();;

                    foreach (var prod in operatorProducts)
                    {
                        ope.Products.Add(prod);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException);
                EventViewerLoggerBL.LogError("GetOperatorProducts: " + ex.Message);
            }

            return(operatorsList);
        }
예제 #9
0
        public SimpleOperationModel AddConsumerNickname(ConsumerEN pConsumer, string pNickname)
        {
            SimpleOperationModel nicknameOp = new SimpleOperationModel();
            bool isForbidden = false;

            try
            {
                var forbiddenNickname = consumerDAL.GetForbiddenNickname(pNickname);

                isForbidden = ValidateIsForbidden(pNickname, 0, forbiddenNickname);

                isForbidden = (isForbidden == false) ? ValidateIsForbidden(pNickname, 1, forbiddenNickname) : true;

                if (isForbidden)
                {
                    nicknameOp.Result  = false;
                    nicknameOp.Message = "forbidden";
                }
                else
                {
                    var nickname = consumerDAL.GetConsumerByNickname(pNickname);

                    if (nickname == null)
                    {
                        pConsumer.Nickname = pNickname;
                        if (consumerDAL.UpdateConsumer(pConsumer) > 0)
                        {
                            nicknameOp.Result  = true;
                            nicknameOp.Message = "updated";
                        }
                        else
                        {
                            nicknameOp.Result  = false;
                            nicknameOp.Message = "error";
                        }
                    }
                    else
                    {
                        nicknameOp.Result  = false;
                        nicknameOp.Message = "conflict";
                    }
                }
            }
            catch (Exception ex)
            {
                nicknameOp = null;
                Console.WriteLine(ex.InnerException);
                EventViewerLoggerBL.LogError(ex.Message);
            }

            return(nicknameOp);
        }
예제 #10
0
        /// <summary>
        /// Generates a new token with renewed expiration date.
        /// </summary>
        /// <param name="pPerson">Vendor data to encrypt</param>
        /// <returns>String: New generated token.</returns>
        public string RenewAuthToken(PersonEN pPerson)
        {
            try
            {
                pPerson.TokenExpiration = DateTime.Now.AddHours(Constants.TokenLifetime);
                pPerson.CurrentToken    = jwt.encode(pPerson);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException);
                EventViewerLoggerBL.LogError(ex.Message);
            }

            return(pPerson.CurrentToken);
        }
예제 #11
0
        public bool VerifyConsumerToken(string pToken, int pConsumerID)
        {
            bool verified = false;

            try
            {
                string masterToken = ConfigurationManager.AppSettings["yocomprorecarga_master_token"].ToString();

                var consumer = consumerDAL.GetConsumerByID(pConsumerID);

                if (consumer != null)
                {
                    if (!String.Equals(pToken, masterToken))
                    {
                        var token = tokenDAL.GetConsumerSmsToken(pConsumerID, pToken, DateTime.Now);

                        if (token != null)
                        {
                            token.Status = true;
                            int updateToken = tokenDAL.UpdateToken(token);

                            if (updateToken > 0)
                            {
                                consumer.Active = true;
                                int updateConsumer = consumerDAL.UpdateConsumer(consumer);

                                verified = (updateConsumer > 0) ? true : false;
                            }
                        }
                    }
                    else
                    {
                        consumer.Active = true;
                        int updateConsumer = consumerDAL.UpdateConsumer(consumer);

                        verified = (updateConsumer > 0) ? true : false;
                    }
                }
            }
            catch (Exception ex)
            {
                verified = false;
                Console.WriteLine(ex.InnerException);
                EventViewerLoggerBL.LogError("VerifyConsumerToken: " + ex.Message);
            }

            return(verified);
        }
예제 #12
0
        //Claro Rocket

        public bool UpdateRocketSalePayment(int BalanceID, int pPaid)
        {
            bool updated = false;

            try
            {
                updated = (saleDAL.UpdateRocketSalePayment(BalanceID, pPaid) > 0) ? true : false;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException);
                EventViewerLoggerBL.LogError("UpdateRocketSalePayment: " + ex.Message);
            }

            return(updated);
        }
예제 #13
0
        public String CreateClientKey(ExternalClientEN pClient)
        {
            String clientKey = "";

            try
            {
                clientKey = jwt.encodeClientKey(pClient);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException);
                EventViewerLoggerBL.LogError(ex.Message);
            }

            return(clientKey);
        }
예제 #14
0
        public ExternalClientEN decodeClientKey(String clientKey)
        {
            ExternalClientEN client = new ExternalClientEN();

            try
            {
                byte[] secretKey = Encoding.ASCII.GetBytes(input);
                client = Jose.JWT.Decode <ExternalClientEN>(clientKey, secretKey);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException);
                EventViewerLoggerBL.LogError("decodeClientKey: " + ex.Message);
            }
            return(client);
        }
예제 #15
0
        public List <BankEN> GetBankList(int pUserCountryID)
        {
            List <BankEN> bankList = new List <BankEN>();

            try
            {
                bankList = bankDAL.GetBanks(pUserCountryID);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException);
                EventViewerLoggerBL.LogError(ex.Message);
            }

            return(bankList);
        }
예제 #16
0
        public ProfileEN GetProfile(int pProfileID)
        {
            ProfileEN userProfile = new ProfileEN();

            try
            {
                userProfile = profileDAL.GetProfile(pProfileID);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException);
                EventViewerLoggerBL.LogError(ex.Message);
            }

            return(userProfile);
        }
예제 #17
0
        public List <OperatorEN> GetOperatorList(int pCountryID)
        {
            List <OperatorEN> operatorsList = new List <OperatorEN>();

            try
            {
                operatorsList = operatorDAL.GetOperators(pCountryID);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException);
                EventViewerLoggerBL.LogError(ex.Message);
            }

            return(operatorsList);
        }
예제 #18
0
        public string GetRocketDealerPin(int PersonID)
        {
            string DealerPin = "";

            try
            {
                DealerPin = saleDAL.GetRocketDealerPin(PersonID);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException);
                EventViewerLoggerBL.LogError("GetRocketDealerPin: " + ex.Message);
            }

            return(DealerPin);
        }
예제 #19
0
        public PromotionEN GetActivePromotion(int pCountryID)
        {
            PromotionEN promo = new PromotionEN();

            try
            {
                promo = promoDAL.GetActivePromotion(pCountryID);
            }
            catch (Exception ex)
            {
                promo = null;
                Console.WriteLine(ex.InnerException);
                EventViewerLoggerBL.LogError("GetActivePromotion: " + ex.Message);
            }

            return(promo);
        }
예제 #20
0
        public RocketBalanceEN GetBalanceRocket(int pPersonID)
        {
            RocketBalanceEN balanceRocket = new RocketBalanceEN();

            try
            {
                balanceRocket = saleDAL.GetBalanceRocket(pPersonID);
            }
            catch (Exception ex)
            {
                balanceRocket = null;
                Console.WriteLine(ex.InnerException);
                EventViewerLoggerBL.LogError(ex.Message);
            }

            return(balanceRocket);
        }
예제 #21
0
        public List <RocketBalanceEN> GetPaymentsHistoryRocket(int pPersonID)
        {
            List <RocketBalanceEN> PaymentsRocket = new List <RocketBalanceEN>();

            try
            {
                PaymentsRocket = saleDAL.GetPaymentsHistoryRocket(pPersonID);
            }
            catch (Exception ex)
            {
                PaymentsRocket = null;
                Console.WriteLine(ex.InnerException);
                EventViewerLoggerBL.LogError(ex.Message);
            }

            return(PaymentsRocket);
        }
예제 #22
0
        public RocketSaleDetailEN GetSaleDetail(int pMasterID, int pPersonID)
        {
            RocketSaleDetailEN councilCount = new RocketSaleDetailEN();

            try
            {
                councilCount = saleDAL.GetSalesDetail(pMasterID, pPersonID);
            }
            catch (Exception ex)
            {
                councilCount = null;
                Console.WriteLine(ex.InnerException);
                EventViewerLoggerBL.LogError(ex.Message);
            }

            return(councilCount);
        }
예제 #23
0
        public List <ProductEN> GetProductsByCountryID(PersonEN pPerson)
        {
            List <ProductEN> products = new List <ProductEN>();

            try
            {
                products = productDAL.GetProductsByCountryID(pPerson.CountryID);
            }
            catch (Exception ex)
            {
                products = null;
                Console.WriteLine(ex.InnerException);
                EventViewerLoggerBL.LogError(ex.Message);
            }

            return(products);
        }
예제 #24
0
        public async Task <List <NotificationResultEN> > SendTopupRequest(string pPersonEmail, string pNickname, string pPhoneRequester, string pAmount, string pFirstname)
        {
            List <NotificationResultEN> camapignResult = new List <NotificationResultEN>();

            try
            {
                camapignResult = await handler.HandleTopupRequestContent(pPersonEmail, pNickname, pPhoneRequester, pAmount, pFirstname);
            }
            catch (Exception ex)
            {
                camapignResult = null;
                Console.WriteLine(ex.InnerException);
                EventViewerLoggerBL.LogError("SendTopupRequest: " + ex.Message);
            }

            return(camapignResult);
        }
예제 #25
0
        public bool MarkNotificationAsRead(int pNotificationID)
        {
            bool read = false;

            try
            {
                read = campaignDAL.MarkNotificationAsRead(pNotificationID);
            }
            catch (Exception ex)
            {
                read = false;
                Console.WriteLine(ex.InnerException);
                EventViewerLoggerBL.LogError("CampaignBL " + ex.Message);
            }

            return(read);
        }
예제 #26
0
        public List <CampaignEN> GetUserNotifications(PersonEN pPerson)
        {
            List <CampaignEN> notifications = new List <CampaignEN>();

            try
            {
                notifications = campaignDAL.GetNotificationsByUserID(pPerson.PersonID);
            }
            catch (Exception ex)
            {
                notifications = null;
                Console.WriteLine(ex.InnerException);
                EventViewerLoggerBL.LogError("CampaignBL " + ex.Message);
            }

            return(notifications);
        }
예제 #27
0
        public ExternalClientEN VerifyExternalClient(IEnumerable <String> pClientKey)
        {
            ExternalClientEN client = null;

            try
            {
                var docodedKey = jwt.decodeClientKey(pClientKey.First().ToString());
                client = clientDAL.AuthenticateClient(docodedKey.GUID, docodedKey.AssignedPassword, docodedKey.RegDate);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException);
                EventViewerLoggerBL.LogError(ex.Message);
            }

            return(client);
        }
예제 #28
0
        public List <PersonBagOperatorEN> GetUserBags(int pPersonID)
        {
            List <PersonBagOperatorEN> personBags = new List <PersonBagOperatorEN>();

            try
            {
                personBags = bagDAL.GetUserOperatorBag(pPersonID);
            }
            catch (Exception ex)
            {
                personBags = null;
                Console.WriteLine(ex.InnerException);
                EventViewerLoggerBL.LogError("GetUserBags: " + ex.Message);
            }

            return(personBags);
        }
예제 #29
0
        public async Task <List <NotificationResultEN> > SendRGOnNotification(CampaignEN pCampaign)
        {
            List <NotificationResultEN> camapignResult = new List <NotificationResultEN>();

            try
            {
                //Send notification
                camapignResult = await handler.HandleRGOPushContent(pCampaign);
            }
            catch (Exception ex)
            {
                camapignResult = null;
                Console.WriteLine(ex.InnerException);
                EventViewerLoggerBL.LogError("CampaignBL " + ex.Message);
            }

            return(camapignResult);
        }
예제 #30
0
        public FacebookConsumerEN authenticateConsumer(string Token)
        {
            FacebookConsumerEN ConsumerDecoded = new FacebookConsumerEN();

            try
            {
                ConsumerAuthEN AuthKey = sessionDAL.GetAuthKey(Token);

                string decodedProfileId = jwt.decodeFacebookID(AuthKey.ConsumerAuthKey);

                ConsumerDecoded = sessionDAL.GetFacebookConsumer(decodedProfileId);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException);
                EventViewerLoggerBL.LogError(ex.Message);
            }

            return(ConsumerDecoded);
        }