Ejemplo n.º 1
0
        public DealsDto[] GetAllActiveDeals(bool canLoadCachedDeals)
        {
            try
            {
                var configLoader = new ConfigHelper();
                if (!canLoadCachedDeals)
                {
                    CacheItemPolicy policy = new CacheItemPolicy();
                    policy.AbsoluteExpiration =
                    DateTimeOffset.Now.AddMinutes(configLoader.GetAppSettingsIntlValue("DealCacheDuration"));
                    var dealsToBind = dDal.GetAllActiveDeals();
                    cacheDealObject.Set("Deals", dealsToBind, policy);
                    return dealsToBind;
                }

                DealsDto[] dealsToBindFromCache = cacheDealObject["Deals"] as DealsDto[];
                if (dealsToBindFromCache == null)
                {
                    CacheItemPolicy policy = new CacheItemPolicy();
                    policy.AbsoluteExpiration =
                    DateTimeOffset.Now.AddMinutes(configLoader.GetAppSettingsIntlValue("DealCacheDuration"));
                    dealsToBindFromCache = dDal.GetAllActiveDeals();
                    cacheDealObject.Set("Deals", dealsToBindFromCache, policy);

                }
                return dealsToBindFromCache;
            }
            catch (Exception ex)
            {
                lBal.LogMessage(ex.InnerException.Message + "at " + ex.StackTrace, LogMessageTypes.Error);
                return null;
            }
        }
Ejemplo n.º 2
0
        public object GetPriceCategories()
        {
            try
            {
                var configLoader = new ConfigHelper();
                List<PriceCategoryDTO> _dealPriceCategories = cachePriceObject["Categories"] as List<PriceCategoryDTO>;
                if (_dealPriceCategories == null)
                {
                    CacheItemPolicy policy = new CacheItemPolicy();
                    policy.AbsoluteExpiration =
                    DateTimeOffset.Now.Date.AddDays(configLoader.GetAppSettingsIntlValue("CategoryPriceCacheDuration"));
                    _dealPriceCategories = iDal.GetPriceCategories();
                    cacheCategoryObject.Set("Categories", _dealPriceCategories, policy);
                }

                return _dealPriceCategories;
            }
            catch (Exception ex)
            {
                lBal.LogMessage(ex.InnerException.Message + "at " + ex.StackTrace, LogMessageTypes.Error);
                return null;
            }
        }
Ejemplo n.º 3
0
 public string GetEncryptedData(string dealID)
 {
     try
     {
         var configLoader = new ConfigHelper();
         var passPhrase = configLoader.GetAppSettingsStringValue("Phrase");
         return EncryptString.Encrypt(dealID, passPhrase);
     }
     catch (Exception ex)
     {
         lBal.LogMessage(ex.InnerException.Message + "at " + ex.StackTrace, LogMessageTypes.Error);
         return string.Empty;
     }
 }
Ejemplo n.º 4
0
 static DataAccess()
 {
     var configLoader = new ConfigHelper();
     IndiaDeals2DayDBConnection = configLoader.GetConnectionStringFromKey(DatabaseConstants.DBname);
 }
Ejemplo n.º 5
0
        public string SendEmailWithPassword(string userName)
        {
            try
            {
            string registeredEmailAddress = uDal.GetRegisteredEmailAddress(userName);
            string password = uDal.GetPassword(userName);
            var configLoader = new ConfigHelper();
            SmtpClient client = new SmtpClient(configLoader.GetAppSettingsStringValue("MailServer"), int.Parse(configLoader.GetAppSettingsStringValue("MailPort")));
            MailAddress from = new MailAddress(configLoader.GetAppSettingsStringValue("EmailSender"),configLoader.GetAppSettingsStringValue("DisplayNameStart")+(char)0xD8+configLoader.GetAppSettingsStringValue("DisplayNameEnd"),System.Text.Encoding.UTF8);
            MailAddress to = new MailAddress(registeredEmailAddress.Trim());
            MailMessage message = new MailMessage(from, to);
            message.Body = "Your password is : " + password;
            message.BodyEncoding = System.Text.Encoding.UTF8;
            message.Subject = "Your password to access Deals4uindia.com";
            client.Credentials = CredentialCache.DefaultNetworkCredentials;
            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            client.Send(message);
            return registeredEmailAddress;
            }

            catch (Exception ex)
            {
                lBal.LogMessage(ex.InnerException.Message + "at " + ex.StackTrace, LogMessageTypes.Error);
                return ex.InnerException.Message;
            }
        }