Exemplo n.º 1
0
 public static int Update(RoleAction o)
 {
     try
     {
         string query = @"UPDATE ""ROLE_ACTION"" SET ""ID"" = @Id, ""ROLE_ID"" = @RoleId, ""ACTION_ID"" = @ActionId, ""IS_ACTIVE"" = @IsActive WHERE ""ID"" = @Id ";
         List <Npgsql.NpgsqlParameter> parameters = new List <NpgsqlParameter>()
         {
             new NpgsqlParameter("@RoleId", DbType.Int32)
             {
                 Value = o.RoleId
             },
             new NpgsqlParameter("@ActionId", DbType.Int32)
             {
                 Value = o.ActionId
             },
             new NpgsqlParameter("@IsActive", DbType.Boolean)
             {
                 Value = o.IsActive
             },
             new NpgsqlParameter("@Id", DbType.Int32)
             {
                 Value = o.Id
             }
         };
         int rowAffected = DBManager.ExecuteNonQueryCommand(query, CommandType.Text, parameters);
         AuditTable.InsertEntity("RoleAction", o.Id.ToString(), 2, DateTime.Now, 1);
         return(rowAffected);
     }
     catch (Exception ex)
     {
         Log.InsertEntity("RoleAction", "Update", 2, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
     }
     return(-1);
 }
Exemplo n.º 2
0
 public static int Insert(RoleAction o)
 {
     try
     {
         string query = @"INSERT INTO ""ROLE_ACTION"" (""ROLE_ID"", ""ACTION_ID"", ""IS_ACTIVE"") VALUES (@RoleId, @ActionId, @IsActive) returning ""ID"" ";
         List <Npgsql.NpgsqlParameter> parameters = new List <NpgsqlParameter>()
         {
             new NpgsqlParameter("@RoleId", DbType.Int32)
             {
                 Value = o.RoleId
             },
             new NpgsqlParameter("@ActionId", DbType.Int32)
             {
                 Value = o.ActionId
             },
             new NpgsqlParameter("@IsActive", DbType.Boolean)
             {
                 Value = o.IsActive
             }
         };
         object id = DBManager.ExecuteScalarCommand(query, CommandType.Text, parameters);
         AuditTable.InsertEntity("RoleAction", id.ToString(), 1, DateTime.Now, 1);
         return(int.Parse(id.ToString()));
     }
     catch (Exception ex)
     {
         Log.InsertEntity("RoleAction", "Insert", 1, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
     }
     return(-1);
 }
Exemplo n.º 3
0
 public static RoleAction GetRoleActionAsObject(DataTable dt)
 {
     foreach (DataRow row in dt.Rows)
     {
         try
         {
             RoleAction o = new RoleAction();
             o.Id       = Helper.ConvertToInt(row["ID"]);
             o.RoleId   = Helper.ConvertToInt(row["ROLE_ID"]);
             o.ActionId = Helper.ConvertToInt(row["ACTION_ID"]);
             o.IsActive = Helper.ConvertToBoolean(row["IS_ACTIVE"]);
             return(o);
         }
         catch (Exception ex)
         {
             Log.InsertEntity("RoleAction", "GetRoleActionAsObject", 1, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
             throw ex;
         }
     }
     return(null);
 }