Ejemplo n.º 1
0
        public async static Task<long> UpdateUserApp(UserApp userApp)
        {
            if (userApp.UserId == 0)
            {
                return 0;
            }
            if (userApp.Id > 0)
            {
                string commandText = @"Update UserApps Set UserId = @userId, IsActive = @isActive, ApiType = @apiType, ApiName = @apiName, ApiKey = @apiKey, ApiSecret = @apiSecret, AppHosts = @appHosts, AppIps = @appIps where Id = @id";
                var parameters = new DynamicParameters();

                parameters.Add("id", userApp.Id);
                parameters.Add("userId", userApp.UserId);
                parameters.Add("isActive", userApp.IsActive ? 1 : 0);
                parameters.Add("apiType", userApp.ApiType.GetHashCode());
                parameters.Add("apiName", userApp.ApiName);
                parameters.Add("apiKey", userApp.ApiKey);
                parameters.Add("apiSecret", userApp.ApiSecret);
                parameters.Add("appHosts", userApp.AppHosts);
                parameters.Add("appIps", userApp.AppIps);
                long results;
                using (var conn = await DataAccessBase.GetOpenAsync(DataAccessBase.QuangAuthConn))
                {
                    
                    results = await conn.ExecuteAsync(commandText, parameters);

                }

                return results;
            }
            else
            {
                return await InsertUserApp(userApp);
            }
        }
Ejemplo n.º 2
0
 private UserApp _parseUserAppObj(Dictionary<string, string> row)
 {
     var userApp = new UserApp
                       {
                           Id = int.Parse(row["Id"]),
                           UserId = int.Parse(row["UserId"]),
                           IsActive = false
                       };
     if (!string.IsNullOrEmpty(row["IsActive"]))
         userApp.IsActive = int.Parse(row["IsActive"]) > 0;
     userApp.ApiType = AppApiType.None;
     if (!string.IsNullOrEmpty(row["ApiType"]) && int.Parse(row["ApiType"]) == 1)
         userApp.ApiType = AppApiType.ClientApi;
     userApp.ApiName = row["ApiName"];
     userApp.ApiKey = row["ApiKey"];
     userApp.ApiSecret = row["ApiSecret"];
     userApp.AppHosts = row["AppHosts"];
     userApp.AppIps = row["AppIps"];
     return userApp;
 }
Ejemplo n.º 3
0
   public int UpdateUserApp(UserApp userApp)
   {
       if (userApp.UserId == 0)
           return 0;
       if (userApp.Id <= 0)
           return InsertUserApp(userApp);
       return _database.Execute("Update UserApps Set " + "UserId = @userId, IsActive = @isActive, ApiType = @apiType, ApiName = @apiName, ApiKey = @apiKey, ApiSecret = @apiSecret, AppHosts = @appHosts, AppIps = @appIps " + "where Id = @id", new Dictionary<string, object>
                                                                                                                                                                                                                                                 {
   {
     "@id",
     userApp.Id
   },
   {
     "@userId",
     userApp.UserId
   },
   {
     "@isActive",
     userApp.IsActive ? 1 : 0
   },
   {
     "@apiType",
     userApp.ApiType.GetHashCode()
   },
   {
     "@apiName",
     userApp.ApiName
   },
   {
     "@apiKey",
     userApp.ApiKey
   },
   {
     "@apiSecret",
     userApp.ApiSecret
   },
   {
     "@appHosts",
     userApp.AppHosts
   },
   {
     "@appIps",
     userApp.AppIps
   }
 });
   }
Ejemplo n.º 4
0
   public int InsertUserApp(UserApp userApp)
   {
       if (userApp.UserId == 0)
           return 0;
       if (userApp.Id > 0)
           return UpdateUserApp(userApp);
       return _database.Execute("Insert Into UserApps  " + "(UserId,  IsActive,  ApiType,  ApiName,  ApiKey,  ApiSecret,  AppHosts,  AppIps) Values " + "(@userId, @isActive, @apiType, @apiName, @apiKey, @apiSecret, @appHosts, @appIps)", new Dictionary<string, object>
                                                                                                                                                                                                                                             {
   {
     "@userId",
     userApp.UserId
   },
   {
     "@isActive",
     userApp.IsActive ? 1 : 0
   },
   {
     "@apiType",
     userApp.ApiType.GetHashCode()
   },
   {
     "@apiName",
     userApp.ApiName
   },
   {
     "@apiKey",
     userApp.ApiKey
   },
   {
     "@apiSecret",
     userApp.ApiSecret
   },
   {
     "@appHosts",
     userApp.AppHosts
   },
   {
     "@appIps",
     userApp.AppIps
   }
 });
   }
Ejemplo n.º 5
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="userApp"></param>
 /// <returns></returns>
 public async static Task<long> UpdateUserApp(UserApp userApp)
 {
     return await UserDal.UpdateUserApp(userApp);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="userApp"></param>
 /// <returns></returns>
 public async static Task<long> InsertUserApp(UserApp userApp)
 {
     return await UserDal.InsertUserApp(userApp);
 }