private string GetUrl()
        {
            string ticks = DateTime.Now.Ticks.ToString();
            string hash  = HashCreator.Create(ticks, _marvelConfig.PublicKey, _marvelConfig.PrivateKey);

            return(string.Concat(_marvelConfig.BaseURL, $"comics?ts={ticks}&apikey={_marvelConfig.PublicKey}&hash={hash}"));
        }
        private string GetUrl(string url)
        {
            if (string.IsNullOrWhiteSpace(url))
            {
                return("");
            }

            string ticks = DateTime.Now.Ticks.ToString();
            string hash  = HashCreator.Create(ticks, _marvelConfig.PublicKey, _marvelConfig.PrivateKey);

            return(string.Concat(url, $"?ts={ticks}&apikey={_marvelConfig.PublicKey}&hash={hash}"));
        }
 public void UpdatePassword(User user)
 {
     try
     {
         var dbManager = new DbManager();
         dbManager.UpdatePassword(user.UserName, HashCreator.Create(user.Password + HashCreator.Key + user.UserName));
     }
     catch (Exception exception)
     {
         LogManager.CurrentInstance.ErrorLogger.LogError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, exception.Message, exception, System.Reflection.MethodBase.GetCurrentMethod().Name);
         throw new ApplicationException("Password updating failed");
     }
 }
Exemple #4
0
 public AuthenticationDetails Login(User user)
 {
     try
     {
         var authenticationDetails = new AuthenticationDetails();
         var dbManager             = new DbManager();
         authenticationDetails.Username = user.UserName;
         authenticationDetails.AuthKey  = dbManager.UserLogin(user.UserName, HashCreator.Create(user.Password + HashCreator.Key + user.UserName));
         if (!Utility.IsNullOrEmpty(authenticationDetails.AuthKey))
         {
             authenticationDetails.LastSyncTime  = Utility.ConvertLocalToUtc(Convert.ToDateTime(dbManager.GetLastSyncTime())).ToString(AppConstants.DateTimeFormat);
             authenticationDetails.LastLoginTime = dbManager.GetLastLoginTime(user.UserName);
             return(authenticationDetails);
         }
         return(null);
     }
     catch (Exception exception)
     {
         LogManager.CurrentInstance.ErrorLogger.LogError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, exception.Message, exception, System.Reflection.MethodBase.GetCurrentMethod().Name);
         throw new ApplicationException("Opertaion failed due to some internal error");
     }
 }