示例#1
0
        /// <summary>
        /// Adds a territory to the Planet
        /// x and y are bound to between 0 and column(x)/Rows(y)
        /// If location is taken, it returns false.
        /// </summary>
        /// <param name="x"/>
        /// <param name="y"/>
        /// <param name="terr">The territory to add.</param>
        /// <param name="context">The context of the planet.</param>
        public bool AddTerritoryToLocation(int x, int y, Territory terr, EconSimContext context)
        {
            // if the location is already taken, return false.
            if (Territories.Any(t => t.X == x && t.Y == y && t.Z == HexZ(x, y)))
            {
                return(false);
            }

            // it's not taken, so add it.
            terr.PlanetId = Id;
            Territories.Add(terr);

            context.Territories.AddOrUpdate(terr);
            context.SaveChanges();

            return(true);
        }
示例#2
0
        static void Main(string[] args)
        {
            inputManager = new CMDInputManager();
            // Initial Loading
            Console.WriteLine("Loading Values ----");
            using (var context = new EconSimContext())
            {
                Console.WriteLine("Product Count: " + context.Products.Count());
                Console.Write("Product Name >>");
                string name = Console.ReadLine();
                context.Products.Add(new Product
                {
                    Name              = name,
                    VariantName       = "",
                    UnitName          = "unit",
                    Quality           = 1,
                    DefaultPrice      = 1.10M,
                    Bulk              = 1,
                    ProductType       = ProductTypes.Good,
                    Maintainable      = false,
                    Fractional        = false,
                    MeanTimeToFailure = 100,
                });

                var products     = context.Products.ToList();
                var failProducts = from m in context.Products
                                   where m.FailsInto != null
                                   select m;

                Console.WriteLine(products.ToString());

                context.SaveChanges();

                Console.WriteLine("NewProductCount = " + context.Products.Count());

                Console.ReadLine();
            }
        }