protected void cmdUpdate_Click(object sender, EventArgs e) { try { InventoryController controller = new InventoryController(); InventoryInfo item = new InventoryInfo(); item.Content = txtContent.Text; item.ItemId = itemId; item.ModuleId = this.ModuleId; item.CreatedByUser = this.UserId; //determine if we are adding or updating if (Null.IsNull(item.ItemId)) { controller.AddInventory(item); } else { controller.UpdateInventory(item); } Response.Redirect(Globals.NavigateURL(), true); } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
/// <summary> /// Drops item into the slot. /// </summary> /// <param name="slot">Slot.</param> public void DropInSlot(Slot newSlot) { // Get old slot Slot oldSlot = GetSlot(); // Update UI UpdateUI(this, newSlot); // Update inventory _inventoryController.UpdateInventory(_item, oldSlot, newSlot); }
public void UpdateInventoryTest() { InventoryController inventoryController = GetController(); Product product = new Product() { Id = 1, Name = "Mobile", Qty = 5, Price = 45000 }; var response = inventoryController.UpdateInventory(product); Response responseMessage = response.Content.ReadAsAsync <Response>().Result; Assert.AreEqual(ErrorCode.SuccessMsg, responseMessage.errorMessage); }
public void UpdateInventoryTest_InvalidQty() { InventoryController inventoryController = GetController(); Product product = new Product() { Id = 12, Name = "Mobile5", Qty = -5, Price = 45000 }; var response = inventoryController.UpdateInventory(product); Response responseMessage = response.Content.ReadAsAsync <Response>().Result; Assert.AreEqual(ErrorCode.InvalidQuantity, responseMessage.Code); }
private void btnUpdateModify_Click(object sender, EventArgs e) { var inventory = new { Name = tbNameModify.Text, Quantity = tbQuantityModify.Text, }; var r = InventoryController.UpdateInventory(inventory); if (r) { tbNameModify.Text = ""; tbQuantityModify.Text = ""; MessageBox.Show("Successfully Updated!"); gridInventories.DataSource = InventoryController.GetAllInventories(); } else { MessageBox.Show("Failed to update"); } }
//Update UI public void UIControl() { invetoryControl.UpdateInventory(); UINickname.text = mercScript.nickname; UIPortrait.sprite = mercScript.portrait; UIHpText.text = mercScript.hp + "/" + mercScript.maxHp; UIHpBar.localScale = new Vector3((float)mercScript.hp / (float)mercScript.maxHp, 1f, 1f); UIStatAccuracy.text = mercScript.accuracy + ""; UIStatStrength.text = mercScript.strength + ""; UIStatAgility.text = mercScript.agility + ""; UIStatReflex.text = mercScript.reflex + ""; if (mercScript.weapon) { UIWeapon.sprite = mercScript.weapon.image; UIWeaponCapacity.text = mercScript.weapon.bulletsLeft + "/" + mercScript.weapon.capacity; if (mercScript.weapon.single) { UIBurstSingle.interactable = true; } else { UIBurstSingle.interactable = false; } if (mercScript.weapon.burst) { UIBurstBurst.interactable = true; } else { UIBurstBurst.interactable = false; } if (mercScript.weapon.auto) { UIBurstAuto.interactable = true; } else { UIBurstAuto.interactable = false; } if (mercScript.weapon.mode == burstMode.single) { UIBurstSingleText.color = Color.red; UIBurstBurstText.color = Color.white; UIBurstAutoText.color = Color.white; } else if (mercScript.weapon.mode == burstMode.burst) { UIBurstSingleText.color = Color.white; UIBurstBurstText.color = Color.red; UIBurstAutoText.color = Color.white; } else if (mercScript.weapon.mode == burstMode.auto) { UIBurstSingleText.color = Color.white; UIBurstBurstText.color = Color.white; UIBurstAutoText.color = Color.red; } } else { UIBurstBurst.interactable = false; UIBurstSingle.interactable = false; UIBurstAuto.interactable = false; UIWeapon.sprite = transparent; UIWeaponCapacity.text = ""; } if (mercScript.armor) { UIArmor.sprite = mercScript.armor.image; } else { UIArmor.sprite = transparent; } if (mercScript.helmet) { UIHelmet.sprite = mercScript.helmet.image; } else { UIHelmet.sprite = transparent; } }