Exemplo n.º 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="permission"></param>
        /// <returns></returns>
        public async static Task<long> Insert(Permission permission)
        {
            string commandText = "Insert into Permissions (Id, Name, Description) values (@id, @name, @description)";
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            if (permission.Id > 0)
            {
                parameters.Add("@id", permission.Id);
            }
            else
            {
                parameters.Add("@id", null);
            }
            parameters.Add("@name", permission.Name);
            parameters.Add("@description", permission.Description);

            long results;

            using (var conn = await DataAccessBase.GetOpenAsync(DataAccessBase.QuangAuthConn))
            {

                var id = await conn.QueryAsync<long>(commandText, parameters);
                results = (long)id.Single();
            }

            return results;
        }
Exemplo n.º 2
0
 public int Insert(Permission permission)
 {
     const string commandText = "Insert into Permissions (Id, Name, Description) values (@id, @name, @description)";
     var parameters = new Dictionary<string, object>();
     if (permission.Id > 0)
         parameters.Add("@id", permission.Id);
     else
         parameters.Add("@id", null);
     parameters.Add("@name", permission.Name);
     parameters.Add("@description", permission.Description);
     return _database.Execute(commandText, parameters);
 }
Exemplo n.º 3
0
   public int Update(Permission permission)
   {
       return _database.Execute("Update Permissions set Name = @name, Description = @description  where Id = @id", new Dictionary<string, object>
                                                                                                                   {
   {
     "@id",
     permission.Id
   },
   {
     "@name",
     permission.Name
   },
   {
     "@description",
     permission.Description
   }
 });
   }
Exemplo n.º 4
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="permission"></param>
 /// <returns></returns>
 public async static Task<long> Update(Permission permission)
 {
     return await PermissionDal.Update(permission);
 }
Exemplo n.º 5
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="permission"></param>
 /// <returns></returns>
 public async static Task<long> Insert(Permission permission)
 {
     return await PermissionDal.Insert(permission);
 }
Exemplo n.º 6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="permission"></param>
        /// <returns></returns>
        public async static Task<long> Update(Permission permission)
        {
            string commandText = "Update Permissions set Name = @name, Description = @description  where Id = @id";
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("@id", permission.Id);
            parameters.Add("@name", permission.Name);
            parameters.Add("@description", permission.Description);

            long results;

            using (var conn = await DataAccessBase.GetOpenAsync(DataAccessBase.QuangAuthConn))
            {

                var id = await conn.ExecuteAsync(commandText, parameters);
                results = id;
            }

            return results;
        }
Exemplo n.º 7
0
   public Permission GetOnePermission(int permissionId)
   {
       var permission = (Permission)null;
       List<Dictionary<string, string>> list = _database.Query("Select * from Permissions where Id = @id", new Dictionary<string, object>
                                                                                                           {
   {
     "@id",
     permissionId
   }
 });
       if (list != null && list.Count == 1)
       {
           var dictionary = list[0];
           permission = new Permission
                        {
                            Id = int.Parse(dictionary["Id"]),
                            Name =
                                string.IsNullOrEmpty(dictionary["Name"])
                                    ? null
                                    : dictionary["Name"],
                            Description =
                                string.IsNullOrEmpty(dictionary["Description"])
                                    ? null
                                    : dictionary["Description"]
                        };
       }
       return permission;
   }