Пример #1
0
        public ActionResult AddItem(string Name, string Descr, double Prices, int Quantity)
        {
            ShopItemModel newItem = new ShopItemModel(Name, Descr, Prices, Quantity);

            Items.Add(newItem);
            return(View("Index", Items));
        }
Пример #2
0
 void OnDetailItemEvent(DetailItemEvent eve)
 {
     Debug.Log("Detail Item diterima:" + eve.ShopItem.Name);
     this.ShopItem = eve.ShopItem;
     Init();
     Enable();
     UpdateCurrentPrice();
 }
Пример #3
0
 internal void AddItem(ShopItemModel itemToUnlock, int v)
 {
     if (!items.ContainsKey(itemToUnlock.uniqueNameID))
     {
         items.Add(itemToUnlock.uniqueNameID, new PlayerItem(itemToUnlock));
     }
     items[itemToUnlock.uniqueNameID].AddExperience(v);
 }
Пример #4
0
        //ShopItem/Taken/1
        public ActionResult Taken(int id)
        {
            ShopItemModel model = _repository.Get(id);

            model.Taken = true;
            _repository.Update(id, model);

            return(RedirectToAction(nameof(Index)));
        }
Пример #5
0
        public async Task <IActionResult> Put([FromBody] ShopItemModel value)
        {
            var shopItem = mapper.Map <ShopItem>(value);
            var res      = await datamanager.Update(shopItem);

            if (res == null)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
            return(Ok(mapper.Map <ShopItemModel>(res)));
        }
Пример #6
0
 private void OnItemClickHandler(ShopItemModel item, ShopItemClickType actionType)
 {
     if (actionType == ShopItemClickType.Select)
     {
         SetSelectedItemModel(item);
     }
     else
     {
         ItemClicked.SafeRaise(item, actionType);
     }
 }
Пример #7
0
        public static bool RemoveItem(ShopItemModel item)
        {
            var arg = CartName + item.ID;

            if (HttpContext.Current.Session[arg] != null)
            {
                HttpContext.Current.Session[arg] = null;
                return(true);
            }

            return(false);
        }
Пример #8
0
        private ShopItemModel GetShopItemModel(PlayerItemInfo currentItem)
        {
            var icon      = SpriteCatalog.GetShopItemSprite(currentItem.ItemType);
            var itemModel = new ShopItemModel(currentItem.ItemType,
                                              icon, currentItem.WorldId);
            var itemInfo = InfoCatalog.GetInfo(currentItem.ItemType);

            itemModel.Name        = itemInfo.Name;
            itemModel.Description = itemInfo.Description;
            UpdateModel(currentItem, itemModel);
            return(itemModel);
        }
Пример #9
0
            public ShopItemModelTestsData()
            {
                var fixture = new Fixture();

                // client has a circular reference from AutoFixture point of view
                fixture.Behaviors.Remove(new ThrowingRecursionBehavior());
                fixture.Behaviors.Add(new OmitOnRecursionBehavior());

                _shopItemModel1 = fixture.Create <ShopItemModel>();
                fixture.Freeze <ShopItemModel>();
                _shopItemModel2 = fixture.Create <ShopItemModel>();
                _shopItemModel3 = fixture.Create <ShopItemModel>();
            }
Пример #10
0
        public ActionResult Edit(ShopItemModel model)
        {
            var valid = true;

            if (valid)
            {
                ShopItems.Instance.UpdateItem(model);
                return(Redirect("/Start/Index"));
            }

            ViewBag.ErrorMessage = "Popraw błędy.";
            return(View(model));
        }
Пример #11
0
        public IActionResult RemoveProduct(int id)
        {
            ShopItemModel item = shopItemService.Get(id).ToModel();

            if (item is null)
            {
                return(RedirectToAction("Product", "Home", new { id = id }));
            }

            shopItemService.Remove(item.ToDomain());

            return(RedirectToAction("Index", "Home"));
        }
Пример #12
0
        public void Update(int id, ShopItemModel model)
        {
            var result = _context.ShopItemList.SingleOrDefault(y => y.ID == id);

            if (result != null)
            {
                result.Name        = model.Name;
                result.Description = model.Description;
                result.Section     = model.Section;
                result.Taken       = model.Taken;
                _context.SaveChanges();
            }
        }
Пример #13
0
 private void SetSelectedItemModel(ShopItemModel item)
 {
     if (_selectedItemModel != null && item != _selectedItemModel)
     {
         _selectedItemModel.IsSelected = false;
         _selectedItemModel.SetChanges();
     }
     _selectedItemModel = item;
     if (_selectedItemModel != null)
     {
         _selectedItemModel.IsSelected = true;
         _selectedItemModel.SetChanges();
     }
 }
Пример #14
0
        public async Task <IActionResult> ProductGet(int?id)
        {
            if (id is null || id < 0)
            {
                return(RedirectToAction("Index"));
            }

            ShopItemModel item = shopItemService.Get((int)id).ToModel();

            if (item is null)
            {
                return(RedirectToAction("Index"));
            }

            return(View((item, await userService.IsManager(User))));
        }
Пример #15
0
        public void CreateItem(ShopItemModel item)
        {
            // DATABASE

            var query =
                "INSERT INTO ShopItems (ID, Name, Description, Value, ImgSrc) " +
                "VALUES (@ID, @Name, @Description, @Value, @ImgSrc)";

            connection.Execute(query, new { item.ID, item.Name, item.Description, item.Value, item.ImgSrc });


            // LOG
            using (var writer = new StreamWriter(logPath, true, Encoding.UTF8))
            {
                writer.WriteLine("({0}) Item added [{1}]", DateTime.Now, item.ID);
            }
        }
Пример #16
0
        public void UpdateItem(ShopItemModel item)
        {
            // DATABASE
            var query =
                "UPDATE ShopItems " +
                "SET Name = @Name, Description = @Description, Value = @Value, ImgSrc = @ImgSrc " +
                "WHERE ID = @ID";

            connection.Execute(query, new { item.ID, item.Name, item.Description, item.Value, item.ImgSrc });


            // LOG
            using (var writer = new StreamWriter(logPath, true, Encoding.UTF8))
            {
                writer.WriteLine("({0}) Item updated [{1}]", DateTime.Now, item.ID);
            }
        }
    IEnumerator LoadItemsRoutine()
    {
        int itItem = 0;

        GameObject  ShopCabinetObj = null;
        ShopCabinet shopCabinet    = null;

        for (int itShopItem = 0; itShopItem < _ShopItemData.ShopItems.Count; itShopItem++)
        {
            ShopItemModel shopItemModel = _ShopItemData.ShopItems [itShopItem];

            if (itItem == 0)
            {
                ShopCabinetObj = Instantiate(Resources.Load(BUTTON_PREFAB) as GameObject);
                ShopCabinetObj.transform.SetParent(this.transform);
                RectTransform rt = ShopCabinetObj.GetComponent <RectTransform> ();
                rt.localScale = new Vector3(1, 1, 1);
                rt.sizeDelta  = new Vector2(rt.sizeDelta.x, rt.sizeDelta.y);

                shopCabinet = ShopCabinetObj.GetComponent <ShopCabinet> ();

                shopCabinet.Item1.ShopItem = shopItemModel;
                shopCabinet.Item1.Init();
            }
            else
            {
                shopCabinet.Item2.ShopItem = shopItemModel;
                shopCabinet.Item2.Init();
            }

            if (itItem < ShopCabinet.MAX_ITEM - 1)
            {
                itItem++;
            }
            else
            {
                itItem = 0;
            }
        }

        _ShopCabinets = GetComponentsInChildren <ShopCabinet> ();

        yield return(null);

        _IsItemLoaded = true;
    }
Пример #18
0
        public ShopItemModelTests()
        {
            var fixture = new Fixture();

            // client has a circular reference from AutoFixture point of view
            fixture.Behaviors.Remove(new ThrowingRecursionBehavior());
            fixture.Behaviors.Add(new OmitOnRecursionBehavior());

            _shopItemModel = new ShopItemModel();
            _category      = new Category
            {
                Id = 1
            };

            fixture.Freeze <ShopItemModel>();
            _shopItemModelLeft  = fixture.Create <ShopItemModel>();
            _shopItemModelRight = fixture.Create <ShopItemModel>();
        }
Пример #19
0
        public static ShopItem ToDomain(this ShopItemModel item)
        {
            if (item is null)
            {
                return(null);
            }

            return(new ShopItem
            {
                Id = item.Id,
                DateCreated = item.DateCreated,
                Name = item.Name,
                Description = item.Description,
                Type = item.Type,
                Price = item.Price,
                Quantity = item.Quantity,
                Images = item.Images
            });
        }
Пример #20
0
        public ActionResult Create(ShopItemModel model)
        {
            var valid = true;

            if (model.Name == null || model.Value < 0)
            {
                valid = false;
            }

            if (valid)
            {
                model.ID = ShopItems.Instance.GetFreeID();
                ShopItems.Instance.CreateItem(model);
                return(Redirect("/Start/Index"));
            }

            ViewBag.ErrorMessage = "Popraw błędy!";
            return(View(model));
        }
Пример #21
0
        public IActionResult AddProduct(ManagerProductViewModel product)
        {
            if (ModelState.IsValid)
            {
                ShopItemModel item = new ShopItemModel()
                {
                    Name        = product.Name,
                    Description = product.Description,
                    Type        = product.Type,
                    Price       = product.Price,
                    Quantity    = product.Quantity,
                    DateCreated = DateTime.Now
                };

                shopItemService.Add(item.ToDomain());

                return(RedirectToAction("Index", "Manager"));
            }
            return(View());
        }
Пример #22
0
        public async Task <IActionResult> ProductPost(int?id)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "User"));
            }

            if (id is null || id < 0)
            {
                return(RedirectToAction("Index"));
            }

            ShopItemModel item = shopItemService.Get((int)id).ToModel();

            if (item is null)
            {
                return(RedirectToAction("Index"));
            }

            cartHelper.AddToCart(HttpContext.Session, item.ToDomain());

            return(View((item, await userService.IsManager(User))));
        }
Пример #23
0
 public DetailItemEvent(ShopItemModel shopItem)
 {
     this.ShopItem = shopItem;
 }
Пример #24
0
        public ActionResult Edit(int id, ShopItemModel model)
        {
            _repository.Update(id, model);

            return(RedirectToAction(nameof(Index)));
        }
Пример #25
0
        public ActionResult Create(ShopItemModel model)
        {
            _repository.Add(model);

            return(RedirectToAction(nameof(Index)));
        }
Пример #26
0
        public void TestEqualsShouldReturnPredictedResultWhenComparingDifferentSetsOfObjects(ShopItemModel a,
                                                                                             ShopItemModel b, bool expectedResult)
        {
            //Arrange

            //Act
            var result = a.Equals(b);

            //Assert
            Assert.Equal(expectedResult, result);
        }
Пример #27
0
        public ActionResult Delete(int id, ShopItemModel model)
        {
            _repository.Delete(id);

            return(RedirectToAction(nameof(Index)));
        }
Пример #28
0
 private void OnItemClicked(ShopItemModel model, ShopItemClickType actionType)
 {
     ItemEvent.SafeRaise(actionType, model.WorldId);
 }
Пример #29
0
 public PlayerItem(ShopItemModel itemToUnlock)
 {
     uniqueItemID = itemToUnlock.uniqueNameID;
 }
Пример #30
0
 private void UpdateModel(PlayerItemInfo itemInfo, ShopItemModel itemModel)
 {
     itemModel.IsInMarket = itemInfo.IsInMarket;
     itemModel.IsEquipped = Model.IsEquipped(itemInfo.WorldId);
     itemModel.SetChanges();
 }