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)); }
void OnDetailItemEvent(DetailItemEvent eve) { Debug.Log("Detail Item diterima:" + eve.ShopItem.Name); this.ShopItem = eve.ShopItem; Init(); Enable(); UpdateCurrentPrice(); }
internal void AddItem(ShopItemModel itemToUnlock, int v) { if (!items.ContainsKey(itemToUnlock.uniqueNameID)) { items.Add(itemToUnlock.uniqueNameID, new PlayerItem(itemToUnlock)); } items[itemToUnlock.uniqueNameID].AddExperience(v); }
//ShopItem/Taken/1 public ActionResult Taken(int id) { ShopItemModel model = _repository.Get(id); model.Taken = true; _repository.Update(id, model); return(RedirectToAction(nameof(Index))); }
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))); }
private void OnItemClickHandler(ShopItemModel item, ShopItemClickType actionType) { if (actionType == ShopItemClickType.Select) { SetSelectedItemModel(item); } else { ItemClicked.SafeRaise(item, actionType); } }
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); }
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); }
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>(); }
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)); }
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")); }
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(); } }
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(); } }
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)))); }
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); } }
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; }
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>(); }
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 }); }
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)); }
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()); }
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)))); }
public DetailItemEvent(ShopItemModel shopItem) { this.ShopItem = shopItem; }
public ActionResult Edit(int id, ShopItemModel model) { _repository.Update(id, model); return(RedirectToAction(nameof(Index))); }
public ActionResult Create(ShopItemModel model) { _repository.Add(model); return(RedirectToAction(nameof(Index))); }
public void TestEqualsShouldReturnPredictedResultWhenComparingDifferentSetsOfObjects(ShopItemModel a, ShopItemModel b, bool expectedResult) { //Arrange //Act var result = a.Equals(b); //Assert Assert.Equal(expectedResult, result); }
public ActionResult Delete(int id, ShopItemModel model) { _repository.Delete(id); return(RedirectToAction(nameof(Index))); }
private void OnItemClicked(ShopItemModel model, ShopItemClickType actionType) { ItemEvent.SafeRaise(actionType, model.WorldId); }
public PlayerItem(ShopItemModel itemToUnlock) { uniqueItemID = itemToUnlock.uniqueNameID; }
private void UpdateModel(PlayerItemInfo itemInfo, ShopItemModel itemModel) { itemModel.IsInMarket = itemInfo.IsInMarket; itemModel.IsEquipped = Model.IsEquipped(itemInfo.WorldId); itemModel.SetChanges(); }