public async Task <IHttpActionResult> PutInventoryList(int id, InventoryList inventoryList) { try { if (id != inventoryList.InventoryID) { return(BadRequest()); } db.Entry(inventoryList).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InventoryListExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); } catch (Exception ex) { throw new HttpResponseException(HttpStatusCode.NotFound); } }
public void SetList() { if (firstSetList) { firstSetList = false; OnceInventoryModel.Param inventory = MonoBehaviourSingleton <OnceManager> .I.result.inventory; equipItemInventory = EquipItemInfo.CreateList(inventory.equipItem); MonoBehaviourSingleton <GameSceneManager> .I.SetNotify(GameSection.NOTIFY_FLAG.UPDATE_EQUIP_INVENTORY); skillItemInventory = SkillItemInfo.CreateList(inventory.skillItem); MonoBehaviourSingleton <GameSceneManager> .I.SetNotify(GameSection.NOTIFY_FLAG.UPDATE_SKILL_INVENTORY); skillMaterialInventory = SkillItemInfo.CreateListFromItem(inventory.item); abilityItemInventory = AbilityItemInfo.CreateList(inventory.abilityItem); inGameTempItemInventory.Clear(); equipItemFilterList.Clear(); itemInventory = ItemInfo.CreateList(inventory.item); abilityItemInventory = InventoryList <AbilityItemInfo, AbilityItem> .CreateList(inventory.abilityItem); SetExpiredAtList(inventory.expiredItem); MonoBehaviourSingleton <GameSceneManager> .I.SetNotify(GameSection.NOTIFY_FLAG.UPDATE_ITEM_INVENTORY); questItemInventory = QuestItemInfo.CreateList(inventory.questItem); MonoBehaviourSingleton <GameSceneManager> .I.SetNotify(GameSection.NOTIFY_FLAG.UPDATE_QUEST_ITEM_INVENTORY); MonoBehaviourSingleton <QuestManager> .I.needRequestOrderQuestList = true; } }
public InventoryScreen(ScreenComponent manager) : base(manager, new Point(400, 300)) { Controls.Add(new Panel(manager) { Position = new Rectangle(20, 20, 360, 40) }); Controls.Add(new Label(manager) { Text = "Rucksack", Position = new Rectangle(40, 30, 0, 0) }); InventoryList list = new InventoryList(manager) { Position = new Rectangle(20, 70, 360, 200) }; foreach (var itemGroup in manager.Game.Local.Player.Inventory.GroupBy(i => i.GetType())) { list.Items.Add(new InventoryItem() { Text = itemGroup.First().Name, Icon = itemGroup.First().Icon, Count = itemGroup.Count() }); } Controls.Add(list); }
/* * Public Methods */ /// <summary> /// Searches all items for a specific item. /// </summary> /// <param name="id">ID of item to search for.</param> /// <returns>Item that was found. If none was found, returns null.</returns> public Item Find(int id) { //Search each item Item item = InventoryList.Find(i => i.ID == id); return(item); }
public InventoryList GetInventoryList(string storeFile) { JsonReader jsr = new JsonReader(); InventoryList il = (InventoryList)jsr.ReadInventoryFile(storeFile); return(il); }
private InventoryList GetInventoryList(SqlDataReader dr, int i) { InventoryList result = null; try { result = new InventoryList(); result.gnum = i; result.itemNo = Convert.ToString(dr["itemNo"]); result.gno = Convert.ToString(dr["gnoCode"]); result.gcode = Convert.ToString(dr["gCode"]); result.gname = Convert.ToString(dr["gName"]); result.gmodel = Convert.ToString(dr["gModel"]); result.barCode = Convert.ToString(dr["barCode"]); result.country = Convert.ToString(dr["goodsCountryCode"]); result.currency = Convert.ToString(dr["goodsCurrency"]); result.qty = Convert.ToSingle(dr["goddsNum"]); result.unit = Convert.ToString(dr["unit1"]); result.qty1 = Convert.ToSingle(dr["goddsNum"]); result.unit1 = Convert.ToString(dr["unit1"]); result.qty2 = Convert.ToSingle(dr["goddsNum"]); result.unit2 = Convert.ToString(dr["unit2"]); result.price = Convert.ToSingle(dr["price"]); result.total = Convert.ToSingle(dr["totalAmount"]); } catch (Exception ex) { throw new Exception("GetInventoryList Exception : " + ex.ToString()); } return(result); }
public void GetResult(string itemName) { InventoryList.Clear(); Task.Factory.StartNew(() => { return(InventoryService.FindItemByName(itemName)); }).ContinueWith(task => { foreach (Inventory result in task.Result) { var quantityOnEbay = InventoryService.FindEBayListingQuantity(result.ItemId); bool potentialOversold = false; if ((result.ExternalQuantity == 0 && result.AmazonQuantity > 0) || (result.ExternalQuantity == 0 && quantityOnEbay > 0)) { potentialOversold = true; } var resultDTO = new InventoryDTO { ItemID = result.ItemId, SKU = result.Sku, Title = result.Title, Quantity = result.ExternalQuantity, Price = result.FixedPrice, QuantityOnEbay = quantityOnEbay, QuantityOnAmazon = result.AmazonQuantity, PotentialOversold = potentialOversold }; InventoryList.Add(resultDTO); } }, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); }
void Start() { currentGameState = EGameState.start; Initialize(); InventoryList <string> inventoryList = new InventoryList <string>(); }
IEnumerator ScrollSelect(int direction) { if (can_scroll == true) { can_scroll = false; InventoryList[] weapons = ingMg.GetWeapons(); if (direction == 1) { current_index = (current_index == 9999999) ? 0 : current_index + 1; } else if (direction == -1) { current_index = (current_index == 9999999) ? weapons.Length - 1 : current_index - 1; } if (current_index < 0 || current_index > weapons.Length - 1) { EnableHands(); } else { InventoryList weapon = ingMg.GetWeaponAtIndex(current_index); if (weapon.id != 9999999) { SelectWeapon(weapon.id); } } yield return(new WaitForSeconds(scrollSelectDelay)); can_scroll = true; } else { yield return(null); } }
public void PopulateItems(InventoryList inventoryList) { // don't want to modify the list in place, instead copy and iterate through that // it Just Works foreach (Transform oldItem in gridHolder.transform.Cast <Transform>().ToArray()) { // Destroy is called after the Update loop, which screws up the first child selection logic // so we do this so it's not shown Destroy(oldItem.gameObject); oldItem.SetParent(null, false); } List <StoredItem> items = inventoryList.GetAll(); for (int i = items.Count - 1; i >= 0; i--) { StoredItem storedItem = items[i]; GameObject g = Instantiate( itemPaneTemplate, Vector2.zero, Quaternion.identity, gridHolder ); g.GetComponent <ItemPane>().PopulateSelfInfo(storedItem); } gridHolder.GetComponent <SelectFirstChild>().OnEnable(); }
public IHttpActionResult PostInventoryList(InventoryList inventoryList) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.InventoryLists.Add(inventoryList); try { db.SaveChanges(); } catch (DbUpdateException) { if (InventoryListExists(inventoryList.itemID)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = inventoryList.itemID }, inventoryList)); }
public IHttpActionResult PutInventoryList(int id, InventoryList inventoryList) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != inventoryList.itemID) { return(BadRequest()); } db.Entry(inventoryList).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!InventoryListExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void UseInventory(Ingredient ingredient) { var totalIndex = TotalInv.IndexOf(TotalInv.Where(i => i.Name == ingredient.Name).FirstOrDefault()); if (totalIndex == -1 || TotalInv[totalIndex].Weight < ingredient.Weight) { Console.WriteLine($"There is not enough {ingredient.Name} in your inventory"); return; } var usedWeight = ingredient.Weight; while (usedWeight > 0) { var listIndex = InventoryList.IndexOf(InventoryList.Where(i => i.Name == ingredient.Name).FirstOrDefault()); if (InventoryList[listIndex].Weight < usedWeight) { usedWeight -= InventoryList[listIndex].Weight; InventoryList.RemoveAt(listIndex); } else { InventoryList[listIndex].Weight -= usedWeight; usedWeight = 0; } } AdjustTotalInventory(ingredient); }
/// <summary> /// Retrieves list of Inventory objects from SqlCommand, after database query /// number of rows retrieved and returned depends upon the rows field value /// </summary> /// <param name="cmd">The command object to use for query</param> /// <param name="rows">Number of rows to process</param> /// <returns>A list of Inventory objects</returns> private InventoryList GetList(SqlCommand cmd, long rows) { // Select multiple records SqlDataReader reader; long result = SelectRecords(cmd, out reader); //Inventory list InventoryList list = new InventoryList(); using ( reader ) { // Read rows until end of result or number of rows specified is reached while (reader.Read() && rows-- != 0) { Inventory inventoryObject = new Inventory(); FillObject(inventoryObject, reader); list.Add(inventoryObject); } // Close the reader in order to receive output parameters // Output parameters are not available until reader is closed. reader.Close(); } return(list); }
private void DoSetup() { InitialFilterSetup(); runnerEquipButton.interactable = false; hackerEquipButton.interactable = false; switch (hackerOrRunner) { case Item.HackerRunner.Runner: hackerContext.SetActive(false); runnerContext.SetActive(true); runnerName.text = runner.GetRunnerName(); runnerDescription.text = runner.GetBio(); currentCardCarosel = runnerCardCarosel; currentInventoryList = runnerInventoryList; foreach (LoadoutSlotBtn button in runnerLoadoutSlotBtns) { button.SetupButton(); } break; case Item.HackerRunner.Hacker: runnerContext.SetActive(false); hackerContext.SetActive(true); hackerName.text = hacker.GetName(); hackerDescription.text = hacker.GetBio(); currentCardCarosel = hackerCardCarosel; SetupActiveHackerSlots(); currentInventoryList = hackerInventoryList; break; } currentCardCarosel.InitializeToggle(); SetupInventoryList(); }
private void ConvertListForEditing(InventoryList itmList, ref List <WillowSaveGame.BankEntry> itmBank) { // Populate itmList with items created from the WillowSaveGame data lists itmList.ClearSilent(); for (int i = 0; i < itmBank.Count; i++) { List <int> itmBankValues = new List <int>() { itmBank[i].Quantity, itmBank[i].Quality, itmBank[i].EquipedSlot, itmBank[i].Level, itmBank[i].Junk, itmBank[i].Locked }; // Store a reference to the parts list List <string> parts = itmBank[i].Strings; // Detach the parts list from the bank entry. itmBank[i].Strings = null; // Items have a different part order in the bank and in the backpack // Part Index Index // Inventory Bank // Item Grade 0 1 // Item Type 1 0 // Body 2 3 // Left 3 4 // Right 4 5 // Material 5 6 // Manufacturer 6 2 // Prefix 7 7 // Title 8 8 int itmType = itmBank[i].TypeId - 1; // Convert all items into the backpack part order. Weapons use // the same format for both backpack and bank. if (itmType == InventoryType.Item) { string temp = parts[1]; parts[1] = parts[0]; parts[0] = temp; temp = parts[2]; parts[2] = parts[3]; parts[3] = parts[4]; parts[4] = parts[5]; parts[5] = parts[6]; parts[6] = temp; } // Create an inventory entry with the re-ordered parts list and add it itmList.AddSilent(new InventoryEntry((byte)(itmBank[i].TypeId - 1), parts, itmBankValues)); //Item/Weapon in bank have their type increase by 1, we reduce TypeId by 1 to manipulate them like other list } itmList.OnListReload(); // Release the WillowSaveGame bank data now that the data is converted // to the format that the WillowTree UI uses. It gets recreated at save time. itmBank = null; }
public StockRequestList(string JsonText) { //Console.WriteLine(JsonText); list = JsonConvert.DeserializeObject <List <StockRequest> >(JsonText); jsr = new JsonReader(); inventory = (InventoryList)jsr.ReadInventoryFile("JSON\\owner_inventory.json"); }
void Start() { Initialize(); InventoryList <string> inventoryList = new InventoryList <string>(); inventoryList.SetItem("Potion"); Debug.Log(inventoryList.item); }
/// <summary> /// Removes an item from the inventory. /// </summary> /// <param name="item">Item to remove.</param> public void Remove(Item item) { if (item == null) { return; } InventoryList.Remove(item); }
public ActionResult List(DateTime bDate, DateTime eDate, string SearchType = "", int codeID = 0, string code = "", int codeID2 = 0, decimal lowValue = 0, decimal highValue = 0) { /* * ViewBag.BeginDate = bDate; * ViewBag.EndDate = eDate; * ViewBag.SearchType = SearchType; * ViewBag.CodeID = codeID; * ViewBag.Code = code; * ViewBag.CodeID2 = codeID2; * ViewBag.LowValue = lowValue; * ViewBag.HighValue = highValue; * */ IEnumerable <propertyinventory> InventoryList; if (SearchType == "AssignedToSearch") { InventoryList = PropertyInventoryRepository.GetInventoryByAssignTo(code); } else if (SearchType == "LocationSearch") { InventoryList = PropertyInventoryRepository.GetInventoryByLocation(code); } else if (SearchType == "PurchaseDateSearch") { InventoryList = PropertyInventoryRepository.GetInventoryByPerchaseDateRange(bDate, eDate); } else if (SearchType == "QuantitySearch") { InventoryList = PropertyInventoryRepository.GetInventoryByQuantityRange(codeID, codeID2); } else if (SearchType == "StatusSearch") { InventoryList = PropertyInventoryRepository.GetInventoryByStatus(code); } else if (SearchType == "TagSearch") { InventoryList = PropertyInventoryRepository.GetInventoryByTag(code); } else if (SearchType == "ValueSearch") { InventoryList = PropertyInventoryRepository.GetInventoryByValueRange(lowValue, highValue); } else if (SearchType == "ConditionSearch") { InventoryList = PropertyInventoryRepository.GetInventoryByCondition(code); } else { InventoryList = PropertyInventoryRepository.GetAllPropertyInventory(); } ViewBag.RecordCount = InventoryList.Count(); GetData(); return(PartialView(InventoryList)); }
public static InventoryList <EquipItemInfo, EquipItem> CreateList(List <EquipItem> recv_list) { InventoryList <EquipItemInfo, EquipItem> list = new InventoryList <EquipItemInfo, EquipItem>(); recv_list.ForEach(delegate(EquipItem o) { list.Add(o); }); return(list); }
public void DisplayPoducts() { JsonReader jsr = new JsonReader(); InventoryList il = (InventoryList)jsr.ReadInventoryFile("JSON\\owner_inventory.json"); //InventoryList il = new InventoryList(); il.PrintItems(); Console.WriteLine("\nPress Any Key To Continue\n"); Console.ReadLine(); }
public void RemoveItemTestAddUnSuccesfull() { // adds successfully InventoryItem item = new InventoryItem(new Product("Pepsi", 1.50m), 0); var numberBeforeRemovingItem = InventoryList.First(c => c.Product.Name == "Pepsi").ProductCount; removeItem(item); Assert.AreEqual((numberBeforeRemovingItem), InventoryList.First(c => c.Product.Name == "Pepsi").ProductCount); }
public void AddItemTestAddSuccesfully() { // adds successfully InventoryItem item = new InventoryItem(new Product("Pepsi", 1.50m), 2); var numberBeforeAddingItem = InventoryList.First(c => c.Product.Name == "Pepsi").ProductCount; addItem(item); Assert.AreEqual((numberBeforeAddingItem + 2), InventoryList.First(c => c.Product.Name == "Pepsi").ProductCount); }
public static InventoryList <T, RECV_DATA> CreateList(List <RECV_DATA> recv_list) { InventoryList <T, RECV_DATA> list = new InventoryList <T, RECV_DATA>(); recv_list.ForEach(delegate(RECV_DATA o) { list.Add(o); }); return(list); }
private void Start() { Initialize(); //implimenting our custom generic class InventoryList //all the InventroyList does is print out when a new InventoryList is initialized InventoryList <string> inventoryList = new InventoryList <string>(); inventoryList.SetItem("Potion"); Debug.Log(inventoryList.item); }
private async Task OnRemoveInventory(object param) { if (param is Inventory) { await inventoryRepo.DeleteInventoryAsync((param as Inventory).Id); InventoryList.Remove(InventoryList.FirstOrDefault(x => x.Id == (param as Inventory).Id)); alertService.Show("Usuwanie towaru", $"Usunięto towar {(param as Inventory).Name}", "Zamknij"); } }
public IHttpActionResult GetInventoryList(int id) { InventoryList inventoryList = db.InventoryLists.Find(id); if (inventoryList == null) { return(NotFound()); } return(Ok(inventoryList)); }
private InventoryManager() { equipItemInventory = new InventoryList <EquipItemInfo, EquipItem>(); skillItemInventory = new InventoryList <SkillItemInfo, SkillItem>(); skillMaterialInventory = new InventoryList <SkillItemInfo, SkillItem>(); itemInventory = new InventoryList <ItemInfo, Item>(); abilityItemInventory = new InventoryList <AbilityItemInfo, AbilityItem>(); inGameTempItemInventory = new List <InGameTempItem>(); questItemInventory = new InventoryList <QuestItemInfo, QuestItem>(); equipItemFilterList = new Dictionary <uint, EquipItemFilter>(); }
private void OnRemoveCommandExecuted() { for (int i = _inventoryList.Count - 1; i >= 0; i--) { if (_inventoryList[i].IsSelected) { _inventoryList.RemoveAt(i); } } AccessionCount = InventoryList.Select(i => i.Item.accession_id).Distinct().Count(); }
public string AddInventoryItemDetails([FromBody]classInventoryItemsDetails objItem) { string IsSuccessOrError = string.Empty; string message = string.Empty; try { using (var dbCtx = new InventoryManagementDBEntities()) { InventoryItemtbl entity = new InventoryItemtbl(); entity.DateOfBuying = objItem.DateOfBuying; // entity.InventoryItemId = objItem.IdDetails; entity.InventoryListId = objItem.IdItem; entity.Location = objItem.Location; entity.Price = objItem.Price; entity.Quantity = objItem.Quantity; entity.UnitType = objItem.UnitType; dbCtx.InventoryItemtbls.Add(entity); dbCtx.SaveChanges(); List<InventoryItemtbl> obj = dbCtx.InventoryItemtbls.Where(p => p.InventoryListId == objItem.IdItem).ToList<InventoryItemtbl>(); int totalPrice = 0; int totalQuantity = 0; foreach (InventoryItemtbl data in obj) { totalQuantity = totalQuantity + Convert.ToInt32(data.Quantity); totalPrice = totalPrice + (Convert.ToInt32(data.Quantity) * Convert.ToInt32(data.Price)); } //if (obj != null) //{ // item.IdDetails = obj.InventoryItemId; // item.IdItem = obj.InventoryListId; // // item.IdUser = obj.UserId; // item.Location = obj.Location; // item.UnitType = obj.UnitType; // item.Price = obj.Price; // item.Quantity = obj.Quantity.ToString(); // item.DateOfBuying = obj.DateOfBuying; // return item; //} InventoryList list = new InventoryList(); list.InventoryListId = objItem.IdItem; list.ItemName = objItem.ItemName; list.TotalCost = totalPrice; list.TotalItems = totalQuantity; dbCtx.Entry(list).State = System.Data.Entity.EntityState.Modified; dbCtx.SaveChanges(); IsSuccessOrError = "Success"; message = "Item has been added successfully."; } //using (var dbCtxInv = new InventoryManagementDBEntities()) //{ // InventoryList list = new InventoryList(); // list.TotalCost = 40000; // var inventoryListsData = dbCtxInv.InventoryLists; // InventoryList inventoryList = inventoryListsData.Where(p => p.InventoryListId == objItem.IdItem).FirstOrDefault<InventoryList>(); // list.ItemName = inventoryList.ItemName; // dbCtxInv.Entry(list).State = System.Data.Entity.EntityState.Modified; // dbCtxInv.SaveChanges(); //} } catch (Exception ex) { message = "Error While adding item in Database." + ex.Message + "inner : " + ex.InnerException + "Id : " + objItem.IdItem + "Name : " + objItem.ItemName; IsSuccessOrError = "Error"; return IsSuccessOrError + ";" + message; } return IsSuccessOrError + ";" + message; }
public string SaveInventoryItemName([FromBody]classItemName objItem) { string IsSuccessOrError = string.Empty; string message = string.Empty; string itemName = objItem.itemName; try { using (var dbCtx = new InventoryManagementDBEntities()) { var inventoryItemDetails = dbCtx.InventoryLists; if (inventoryItemDetails != null) { InventoryList obj = inventoryItemDetails.Where(p => p.ItemName == itemName).FirstOrDefault<InventoryList>(); if (obj == null) { InventoryList objInventoryList = new InventoryList(); objInventoryList.ItemName = itemName; dbCtx.InventoryLists.Add(objInventoryList); dbCtx.SaveChanges(); IsSuccessOrError = "Success"; } else { message = "Item is already exists in system."; IsSuccessOrError = "Error"; } } } } catch (Exception ex) { IsSuccessOrError = "Error" + ";" + ex.Message; return IsSuccessOrError; } return IsSuccessOrError + ";" + message; }