Exemplo n.º 1
0
        // ---------------- Constructor ----------------

        protected AssetModel(IAssetManagerApi api, Asset asset, int assetTypeId, IAssetType assetType)
        {
            this.Api         = api;
            this.Asset       = asset;
            this.AssetTypeId = assetTypeId;
            this.AssetType   = assetType;
        }
Exemplo n.º 2
0
        // ---------------- Constructor ----------------

        public AssetListModel(IAssetManagerApi api, AssetListInfo listInfo)
        {
            this.DatabaseId  = listInfo.DatabaseId;
            this.Api         = api;
            this.AssetName   = listInfo.AssetTypeName;
            this.AssetTypeID = listInfo.AssetTypeId;
            this.Assets      = listInfo.AssetList;
        }
Exemplo n.º 3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            IAssetManagerApi api = AssetManagerApiFactory.CreateApiFromDefaultConfigFile();

            services.AddSingleton(api);

            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });


            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
        }
Exemplo n.º 4
0
        static int Main(string[] args)
        {
            try
            {
                IAssetManagerApi api = AssetManagerApiFactory.CreateApiFromDefaultConfigFile();

                AddTradingCards(api);
                AddVideoGames(api);
                return(0);
            }
            catch (Exception e)
            {
                Console.WriteLine("UNHANDLED EXCEPTION:");
                Console.Write(e.ToString());
                return(-1);
            }
        }
Exemplo n.º 5
0
        private static void AddVideoGames(IAssetManagerApi api)
        {
            if (File.Exists(@"C:\Users\xfore\Downloads\VideoGames.db"))
            {
                File.Delete(@"C:\Users\xfore\Downloads\VideoGames.db");
            }

            Guid databaseId = api.DataBase.DatabaseNames.First(n => n.Value == "VideoGames").Key;

            AssetTypeBuilder builder = new AssetTypeBuilder("PC Games", databaseId);

            AssetNameAttributeType assetNameType = new AssetNameAttributeType
            {
                Key      = "Title",
                Required = true
            };

            builder.AttributeTypes.Add(assetNameType);

            IntegerAttributeType releaseYear = new IntegerAttributeType
            {
                Key      = "Release Year",
                Required = true
            };

            builder.AttributeTypes.Add(releaseYear);

            int pcGameId = api.DataBase.AddAssetType(builder);

            {
                Asset asset = api.DataBase.GenerateEmptyAsset(databaseId, pcGameId);
                asset.SetAttribute("Title", new AssetNameAttribute("Command and Conquer"));
                asset.SetAttribute("Release Year", new IntegerAttribute {
                    Value = 1995
                });
                api.DataBase.AddAsset(asset);
            }
        }
Exemplo n.º 6
0
 public AboutController([FromServices] IAssetManagerApi api) :
     base(api)
 {
 }
Exemplo n.º 7
0
 public static string GetWebVersion(this IAssetManagerApi api)
 {
     return(typeof(ApiExtensions).Assembly.GetName().Version.ToString());
 }
Exemplo n.º 8
0
 public static IReadOnlyList <CreditsInfo> GetCredits(this IAssetManagerApi api)
 {
     return(CreditsInfo.AllCredits);
 }
Exemplo n.º 9
0
        // ---------------- Constructor ----------------

        public DefaultModel(IAssetManagerApi api)
        {
            this.Api = api;
        }
Exemplo n.º 10
0
        // ---------------- Constructor ----------------

        public ErrorModel(IAssetManagerApi api)
        {
            this.Message        = "Unknown Error :(";
            this.HttpStatusCode = HttpStatusCode.InternalServerError;
            this.Api            = api;
        }
Exemplo n.º 11
0
 public EditAssetModel(IAssetManagerApi api, Asset asset, int assetTypeId, IAssetType assetType, int assetId) :
     base(api, asset, assetTypeId, assetType)
 {
     this.AssetId = assetId;
 }
Exemplo n.º 12
0
 public AddAssetModel(IAssetManagerApi api, Asset asset, int assetTypeId, IAssetType assetType) :
     base(api, asset, assetTypeId, assetType)
 {
 }
Exemplo n.º 13
0
        // ---------------- Constructor ----------------

        protected BaseController(IAssetManagerApi api)
        {
            this.Api = api;
        }
Exemplo n.º 14
0
        // ---------------- Constructor ----------------

        public AddAssetTypeController([FromServices] IAssetManagerApi api) :
            base(api)
        {
        }
Exemplo n.º 15
0
        // ---------------- Constructor ----------------

        public AssetTypeInfoModel(DatabaseQueryMultiResult <IList <AssetTypeInfo> > queryResult, IAssetManagerApi api)
        {
            this.Api = api;

            List <AssetTypeInfo> infoList  = new List <AssetTypeInfo>();
            List <string>        errorList = new List <string>();

            foreach (DatabaseQueryResult <IList <AssetTypeInfo> > info in queryResult.Results.Values)
            {
                if (info.Success)
                {
                    foreach (AssetTypeInfo assetTypeInfo in info.Result)
                    {
                        infoList.Add(assetTypeInfo);
                    }
                }
                else
                {
                    errorList.Add(api.DataBase.DatabaseNames[info.DatabaseId] + ": " + info.Error.Message);
                }
            }

            this.AssetTypeInfo = infoList.AsReadOnly();
            this.Errors        = errorList.AsReadOnly();
        }
Exemplo n.º 16
0
        private static void AddTradingCards(IAssetManagerApi api)
        {
            if (File.Exists(@"C:\Users\xfore\Downloads\TradingCards.db"))
            {
                File.Delete(@"C:\Users\xfore\Downloads\TradingCards.db");
            }

            Guid databaseId = api.DataBase.DatabaseNames.First(n => n.Value == "TradingCards").Key;

            int pokemonCardTypeId = -1;
            {
                AssetTypeBuilder builder = new AssetTypeBuilder("Pokemon Card", databaseId);

                AssetNameAttributeType assetNameType = new AssetNameAttributeType
                {
                    Key      = "Card Name",
                    Required = true
                };
                builder.AttributeTypes.Add(assetNameType);

                IntegerAttributeType hpAttribute = new IntegerAttributeType
                {
                    Key          = "HP",
                    MinValue     = 10,
                    Required     = false,
                    DefaultValue = 50
                };

                builder.AttributeTypes.Add(hpAttribute);

                IntegerAttributeType retreatCostAttribute = new IntegerAttributeType
                {
                    Key      = "Retreat Cost",
                    MinValue = 0,
                    MaxValue = 4,
                    Required = false
                };
                builder.AttributeTypes.Add(retreatCostAttribute);

                StringAttributeType flavorText = new StringAttributeType
                {
                    Key      = "Flavor Text",
                    Required = true
                };
                builder.AttributeTypes.Add(flavorText);

                pokemonCardTypeId = api.DataBase.AddAssetType(builder);
            }

            int yugiohCardTypeId = -1;
            {
                AssetTypeBuilder builder = new AssetTypeBuilder("Yugioh! Card", databaseId);

                AssetNameAttributeType assetNameType = new AssetNameAttributeType
                {
                    Key      = "Card Name",
                    Required = true
                };
                builder.AttributeTypes.Add(assetNameType);

                IntegerAttributeType attackAttribute = new IntegerAttributeType
                {
                    Key      = "Attack",
                    MinValue = 0,
                    Required = true
                };
                builder.AttributeTypes.Add(attackAttribute);

                IntegerAttributeType defenseAttribute = new IntegerAttributeType
                {
                    Key      = "Defense",
                    MinValue = 0,
                    Required = true
                };
                builder.AttributeTypes.Add(defenseAttribute);

                yugiohCardTypeId = api.DataBase.AddAssetType(builder);
            }

            {
                Asset asset = api.DataBase.GenerateEmptyAsset(databaseId, pokemonCardTypeId);
                asset.SetAttribute("Card Name", new AssetNameAttribute("Politoed"));
                asset.SetAttribute("HP", new IntegerAttribute()
                {
                    Value = 100
                });
                asset.SetAttribute("Retreat Cost", new IntegerAttribute()
                {
                    Value = 3
                });
                asset.SetAttribute(
                    "Flavor Text",
                    new StringAttribute
                {
                    Value =
                        @"Whenever 3 or more of these get together,
they sing in an lound voice that sounds like bellowing."
                }
                    );

                api.DataBase.AddAsset(asset);
            }

            {
                Asset asset = api.DataBase.GenerateEmptyAsset(databaseId, yugiohCardTypeId);
                asset.SetAttribute("Card Name", new AssetNameAttribute("The 13th Grave"));

                IntegerAttribute attackAttr = asset.CloneAttributeAsType <IntegerAttribute>("Attack");
                attackAttr.Value = 1200;
                asset.SetAttribute("Attack", attackAttr);

                IntegerAttribute defenseAttr = asset.CloneAttributeAsType <IntegerAttribute>("Defense");
                defenseAttr.Value = 900;
                asset.SetAttribute("Defense", attackAttr);

                api.DataBase.AddAsset(asset);
            }

            {
                Asset asset = api.DataBase.GenerateEmptyAsset(databaseId, yugiohCardTypeId);
                asset.SetAttribute("Card Name", new AssetNameAttribute("Overdrive"));
                asset.SetAttribute("Attack", new IntegerAttribute(1600));
                asset.SetAttribute("Defense", new IntegerAttribute(1500));

                api.DataBase.AddAsset(asset);
            }
        }