Exemplo n.º 1
0
    void GenerateStoreItems(Inventorys inventory)
    {
        if (inventory.items.Count == 0)
        {
            CloseStoreUI();
            return;
        }

        isStoreOpen = true;
        gameObject.SetActive(true);
        itemTemplate.gameObject.SetActive(true);

        storeItems = new Stock[inventory.items.Count];

        for (int i = 0; i < inventory.items.Count; i++)
        {
            storeItems[i] = new Stock(itemTemplate, "ItemAreaMask", inventory.items[i]);
            storeItems[i].itemPanel.anchoredPosition = new Vector2(0, i * -100);

            UnityEngine.UI.Image image = storeItems[i].itemPanel.FindChild("Panel").GetComponent<UnityEngine.UI.Image>();
            image.color = new Color(i / 9f, 0.2f, 0.7f);
        }

        itemTemplate.gameObject.SetActive(false);
    }
Exemplo n.º 2
0
        public async Task <ActionResult> Create(Inventorys inv)
        {
            try
            {
                string jsonString = JsonConvert.SerializeObject(inv);

                var request = new HttpRequestMessage(HttpMethod.Post, "api/inventorys");
                {
                    // we set what the Content-Type header will be here
                    request.Content = new StringContent(jsonString, Encoding.UTF8, "application/json");
                };

                var response = await HttpClient.SendAsync(request);

                if (!response.IsSuccessStatusCode)
                {
                    return(View("Error"));
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 3
0
        public IEnumerable <VechicleViewModel> GetAll()
        {
            List <VechicleViewModel> repo = new List <VechicleViewModel>();

            return(Inventorys.Include("Mdles").Include("Typs").Include("BodyStyles")
                   .Include("Transmissions").Include("Colors").Include("Interiors")
                   .Include("PurchaseTypes").Select(i => new VechicleViewModel
            {
                InventoryId = i.Id,
                Make = i.Mdles.Makes.MakeName,
                Model = i.Mdles.ModelName,
                Type = i.Typs.TypeName,
                BodyStyle = i.BodyStyles.BodyStyleName,
                Year = i.Year,
                Transmission = i.Transmissions.TransmissionName,
                Color = i.Colors.ColorName,
                Interior = i.Interiors.InteriorName,
                Mileage = i.Mileage,
                VIN = i.VIN,
                MSRP = i.MSRP,
                SalesPrice = i.SalesPrice,
                Description = i.Description,
                Picture = i.Picture,
                FeatureVehicle = i.FeatureVehicle,
                StillAvailable = i.PurchaseTypeId == null ? "Yes" : "No",
                SalesId = i.SalesPersonId,
                PurchasedPrice = i.PurchasePrice,
                PurhasedDate = i.PurchaseDate
            }));
        }
Exemplo n.º 4
0
        public async void GetInventorysFromDatabaseTest()
        {
            var options = new DbContextOptionsBuilder <CheapWareContext>()
                          .UseInMemoryDatabase(databaseName: "GetCustomersFromDatabase")
                          .Options;
            var inventory = new Inventorys {
                Name = "test product", Quantity = 30, Category = "CPUs", Price = 139.99M
            };
            List <Inventory> listofinventorys = null;

            using (var context = new CheapWareContext(options))
            {
                context.Add(inventory);
                context.SaveChanges();
            }

            using (var context = new CheapWareContext(options))
            {
                var service = new ComputerRepo(context);
                listofinventorys = await service.GetInventory();
            }


            using (var context = new CheapWareContext(options))
            {
                Assert.Single(listofinventorys);
                Assert.Equal("test product", context.Inventorys.Single().Name);
            }
        }
Exemplo n.º 5
0
        public async void GetInventoryByCategoryTest()
        {
            var options = new DbContextOptionsBuilder <CheapWareContext>()
                          .UseInMemoryDatabase(databaseName: "GetInventoryByCategoryDatabase")
                          .Options;
            var inventory1 = new Inventorys {
                Name = "test name1", Quantity = 30, Category = "CPU", Price = 129.99M
            };
            var inventory2 = new Inventorys {
                Name = "test name2", Quantity = 50, Category = "HardDrive", Price = 129.99M
            };

            List <Inventory> listofinventorys = null;

            using (var context = new CheapWareContext(options))
            {
                context.Add(inventory1);
                context.Add(inventory2);
                context.SaveChanges();
            }

            using (var context = new CheapWareContext(options))
            {
                var service = new ComputerRepo(context);
                listofinventorys = await service.GetInventoryByCategory("CPU");
            }


            using (var context = new CheapWareContext(options))
            {
                Assert.Single(listofinventorys);
                Assert.Equal("test name1", listofinventorys.First().Name);
            }
        }
Exemplo n.º 6
0
        public VechicleViewModel GetInventorysById(int id)
        {
            VechicleViewModel temp = Inventorys.Where(p => p.Id == id).Include("Mdles").Include("Typs").Include("BodyStyles")
                                     .Include("Transmissions").Include("Colors").Include("Interiors")
                                     .Include("PurchaseTypes").Select(i => new VechicleViewModel
            {
                InventoryId    = i.Id,
                Make           = i.Mdles.Makes.MakeName,
                Model          = i.Mdles.ModelName,
                Type           = i.Typs.TypeName,
                BodyStyle      = i.BodyStyles.BodyStyleName,
                Year           = i.Year,
                Transmission   = i.Transmissions.TransmissionName,
                Color          = i.Colors.ColorName,
                Interior       = i.Interiors.InteriorName,
                Mileage        = i.Mileage,
                VIN            = i.VIN,
                MSRP           = i.MSRP,
                SalesPrice     = i.SalesPrice,
                Description    = i.Description,
                Picture        = i.Picture,
                FeatureVehicle = i.FeatureVehicle,
                StillAvailable = i.PurchaseTypeId == null ? "Yes" : "No"
            }).FirstOrDefault();

            return(temp);
        }
Exemplo n.º 7
0
        public void Purchased(PurchaseInfo purchase, int salesId)
        {
            var vechicle = Inventorys.Where(i => i.Id == purchase.VechicleId).First();

            vechicle.PurchasePrice  = purchase.Purchase;
            vechicle.PurchaseTypeId = Inventorys.Where(p => p.PurchaseTypes.PurchaseTypeName == purchase.PurchaseType).First().PurchaseTypeId;
            vechicle.FeatureVehicle = false;
            vechicle.PurchaseDate   = DateTime.Now;
            vechicle.SalesPersonId  = salesId;
            (this).SaveChanges();
        }
Exemplo n.º 8
0
        public InventoryViewModel ChangeInventory(Inventorys inventory)
        {
            InventoryViewModel inventoryModel = new InventoryViewModel
            {
                CreateTime    = inventory.CreateTime,
                InventoryId   = inventory.InventoryId,
                InventoryName = inventory.InventoryName,
                UserId        = inventory.UserId,
            };

            return(inventoryModel);
        }
Exemplo n.º 9
0
        public void SaveInventory(IDataInventory inventory, IDataProduct product, IDataStore store)
        {
            using DbRestaurantContext context = new DbRestaurantContext();
            var I_Inventory = new Inventorys();

            // add BusinessLogic Inventory to DbInventory
            I_Inventory.ProductId = product.ProductId;
            I_Inventory.StoreId   = store.StoreId;

            I_Inventory.Quantity = inventory.Quantity;


            context.Add(I_Inventory);
            context.SaveChanges();
        }
Exemplo n.º 10
0
        public void DeleteVehicle(int id)
        {
            Inventory item = Inventorys.Where(i => i.Id == id).FirstOrDefault();

            if (item != null)
            {
                var    file = item.Picture;
                string path = Path.Combine(HttpContext.Current.Server.MapPath("~/Images"),
                                           Path.GetFileName(file));
                File.Delete(path);

                Inventorys.Remove(item);
                (this).SaveChanges();
            }
        }
Exemplo n.º 11
0
        public void EditVechicle(VechicleViewModel vechicle)
        {
            var editVehicle = Inventorys.Include("Mdles").Include("Typs").Include("BodyStyles")
                              .Include("Transmissions").Include("Colors").Include("Interiors")
                              .Include("PurchaseTypes").FirstOrDefault(p => p.Id == vechicle.InventoryId);

            editVehicle.Id           = vechicle.InventoryId;
            editVehicle.Mdles.MakeId = Makes.FirstOrDefault(p => p.MakeName == vechicle.Make).MakeId;
            editVehicle.MdleId       = Models.FirstOrDefault(p => p.ModelName == vechicle.Model).MdleId;

            editVehicle.BodyStyleId    = BodyStyles.FirstOrDefault(p => p.BodyStyleName == vechicle.BodyStyle).BodyStyleId;
            editVehicle.ColorId        = Colors.SingleOrDefault(p => p.ColorName == vechicle.Color).ColorId;
            editVehicle.TypId          = Typs.SingleOrDefault(p => p.TypeName == vechicle.Type).TypId;
            editVehicle.Year           = vechicle.Year;
            editVehicle.TransmissionId = Transmissions.SingleOrDefault(p => p.TransmissionName == vechicle.Transmission).TransmissionId;
            editVehicle.InteriorId     = Interiors.FirstOrDefault(p => p.InteriorName == vechicle.Interior).InteriorId;
            editVehicle.Mileage        = vechicle.Mileage;
            editVehicle.VIN            = vechicle.VIN;
            editVehicle.MSRP           = vechicle.MSRP;
            editVehicle.SalesPrice     = vechicle.SalesPrice;
            editVehicle.Description    = vechicle.Description;

            editVehicle.FeatureVehicle = vechicle.FeatureVehicle;
            if (editVehicle.Picture != null)
            {
                var    oldFile = editVehicle.Picture;
                string path    = Path.Combine(HttpContext.Current.Server.MapPath("~/Images"),
                                              Path.GetFileName(oldFile));
                File.Delete(path);
            }

            if (vechicle.File != null && vechicle.File.ContentLength > 0)
            {
                string[] fileName = vechicle.File.FileName.Split('.');
                string   newName  = "inventory-" + editVehicle.Id + "." + fileName.Last();


                string path = Path.Combine(HttpContext.Current.Server.MapPath("~/Images"),
                                           Path.GetFileName(newName));

                vechicle.File.SaveAs(path);
                editVehicle.Picture = newName;
            }



            (this).SaveChanges();
        }
Exemplo n.º 12
0
        public TestEnemy()
        {
            Name   = "测试敌人";
            UnitHp = UnitMaxHp = 25;
            Equipments.UnitWeapon = new BaseWoodSword();

            //掉落设定
            Inventorys.Add(new BaseWoodOrcCycle());
            Inventorys.Add(new BaseWoodSword());
            Inventorys.Add(new SwordShieldFunBook());
            Inventorys.Add(new GoldStone());
            Inventorys.Add(new GoldStone());
            Inventorys.Add(new WoodStone());
            Inventorys.Add(new WaterStone());
            Inventorys.Add(new FireStone());
            Inventorys.Add(new SoilStone());
            Inventorys.Add(new Wolfskin());
            Inventorys.Add(new Wolfskin());
            Inventorys.Add(new Wolfskin());


            ManMadeCard card = new ManMadeCard();

            card.Name       = "千机变";
            card.EnergyCost = 1;
            card.CardType   = Card.CardTypes.灵;
            card.Describe   = "万法千机,随机应变";
            card.CardSkills.Add(new BasalAtk(1));
            card.CardSkills.Add(new GetHurt(1));
            card.CardSkills.Add(new GetLing(1));
            card.CardSkills.Add(new GetShield(3));
            ManMadeWeapon w = new ManMadeWeapon();

            w.Name       = "千机伞*改";
            w.WeaponType = TheFiveElements.Gold;
            w.WeaponCards.Add(card);
            w.WeaponCards.Add(card);
            w.WeaponCards.Add(new BasalAtkCard());
            w.WeaponCards.Add(new BaseSwordAtkCard());
            w.WeaponCards.Add(new GiveShieldCard());
            w.WeaponCards.Add(new LingSwordAtkCard());


            Inventorys.Add(w);
            Inventorys.Add(w);
        }
Exemplo n.º 13
0
        public PlayerUnit()
        {
            Name   = "赵日天";
            UnitHp = UnitMaxHp = 50;
            Inventorys.Add(new GoldStone(0));
            Inventorys.Add(new WoodStone(0));
            Inventorys.Add(new WaterStone(0));
            Inventorys.Add(new FireStone(0));
            Inventorys.Add(new SoilStone(0));

            ManMadeWeapon temp = new ManMadeWeapon();

            temp.Name       = "千机伞";
            temp.WeaponType = TheFiveElements.Gold;
            temp.WeaponCards.Add(new BasalAtkCard());
            temp.WeaponCards.Add(new BaseSwordAtkCard());
            temp.WeaponCards.Add(new GiveShieldCard());
            temp.WeaponCards.Add(new LingSwordAtkCard());
            Inventorys.Add(temp);
            Inventorys.Add((ManMadeWeapon)temp.Clone());
        }
Exemplo n.º 14
0
        /// <summary>
        /// 创建清单
        /// 一个用户不能拥有重复的清单名字
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="inventoryName"></param>
        /// <returns></returns>
        public bool CreateInventory(int userId, string inventoryName)
        {
            var userInventory = _database.Inventorys.Where(user => user.UserId == userId).ToList();
            var inventory     = userInventory.SingleOrDefault(list => list.InventoryName.Equals(inventoryName));

            if (inventory == null)
            {
                var newInventory = new Inventorys()
                {
                    InventoryName = inventoryName,
                    CreateTime    = DateTime.Now,
                    UserId        = userId,
                };
                _database.Inventorys.Add(newInventory);
                _database.SaveChanges();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 15
0
        public VechicleViewModel AddVechicle(AddVehicleViewModel vechicle)
        {
            Inventory newInventory = new Inventory();

            newInventory.Id             = Inventorys.Max(i => i.Id) + 1;
            newInventory.Mdles          = GetAllModels().First(m => m.Makes.MakeName == vechicle.Make);
            newInventory.MdleId         = newInventory.Mdles.MdleId;
            newInventory.TypId          = GetAllTypes().SingleOrDefault(t => t.TypeName == vechicle.Type).TypId;
            newInventory.BodyStyleId    = GetAllBodyStyles().SingleOrDefault(b => b.BodyStyleName == vechicle.BodyStyle).BodyStyleId;
            newInventory.Year           = vechicle.Year;
            newInventory.TransmissionId = GetAllTransmissions().Where(t => t.TransmissionName == vechicle.Transmission).Single().TransmissionId;
            newInventory.ColorId        = GetAllColors().Where(c => c.ColorName == vechicle.Color).Single().ColorId;
            newInventory.InteriorId     = GetAllInteriors().Where(i => i.InteriorName == vechicle.Interior).Single().InteriorId;
            newInventory.Mileage        = vechicle.Mileage;
            newInventory.VIN            = vechicle.VIN;
            newInventory.MSRP           = vechicle.MSRP;
            newInventory.SalesPrice     = vechicle.SalesPrice;
            newInventory.Description    = vechicle.Description;

            if (vechicle.File != null && vechicle.File.ContentLength > 0)
            {
                string[] fileName = vechicle.File.FileName.Split('.');
                string   newName  = "inventory-" + newInventory.Id + "." + fileName.Last();


                string path = Path.Combine(HttpContext.Current.Server.MapPath("~/Images"),
                                           Path.GetFileName(newName));

                vechicle.File.SaveAs(path);
                newInventory.Picture = newName;
            }

            Inventorys.Add(newInventory);

            (this).SaveChanges();


            return(GetInventorysById(newInventory.Id));
        }
Exemplo n.º 16
0
        // GET: Inventorys/Details/5
        public async Task <ActionResult> Details(string name)
        {
            var request = CreateRequestToService(HttpMethod.Get, "api/inventorys/" + name);

            try
            {
                var response = await HttpClient.SendAsync(request);

                if (!response.IsSuccessStatusCode)
                {
                    return(View("Error"));
                }
                string jsonString = await response.Content.ReadAsStringAsync();

                Inventorys inv = JsonConvert.DeserializeObject <Inventorys>(jsonString);

                return(View(inv));
            }
            catch (HttpRequestException)
            {
                return(View("Error"));
            }
        }
Exemplo n.º 17
0
 void Start()
 {
     inventory = GameObject.FindGameObjectWithTag("Player").GetComponent <Inventorys>();
 }