public List <UserInventory> GetUserInventory(uint userid, bool b, int id) { List <UserInventory> rDetails = new List <UserInventory>(); using (DatabaseClient dbClient = AleedaEnvironment.GetDatabase().GetClient()) { if (b == true) { dbClient.AddParamWithValue("@userid", userid); foreach (DataRow row in dbClient.ReadDataTable("SELECT * FROM user_inventory WHERE userid = @userid").Rows) { UserInventory details = UserInventory.Parse(row, false); if (details != null) { rDetails.Add(details); } } } else if (b == false) { dbClient.AddParamWithValue("@id", id); foreach (DataRow row in dbClient.ReadDataTable("SELECT * FROM user_inventory WHERE id = @id").Rows) { UserInventory details = UserInventory.Parse(row, false); if (details != null) { rDetails.Add(details); } } } } return(rDetails); }
public static UserInventory Parse(DataRow row, bool b) { UserInventory details = new UserInventory(); try { if (!b) { details.mID = (int)row["id"]; details.mName = (string)row["name"]; details.spriteID = (int)row["sprite_id"]; details.mType = (string)row["type"]; } else if (b) { details.mID = (int)row["id"]; details.petname = (string)row["petname"]; details.race = (int)row["race"]; details.colour = (string)row["color"]; } return(details); } catch (Exception ex) { AleedaEnvironment.GetLog().WriteUnhandledExceptionError("UserInventory.Parse", ex); } return(null); }