public string CategoryToName(SupplyItem item) { if (item.CategoryId != null) { var data = _categoryRepository.FirstOrDefault(i => i.Id == item.CategoryId); return data.Name; } return ""; }
public SupplyItem AddProductToSupplyQueue(SupplyItem item) { _applicationContext.SupplyQueue.Add(item); try { _applicationContext.SaveChanges(); return(item); } catch (InvalidDataException e) { Console.WriteLine(e.Message); throw; } }
private void AddAllPSupplyItems() { foreach (var item in _currentPurchase.PurchaseItems) { var supplyItem = new SupplyItem() { PurchaseItemID = item.PurchaseItemID, PurchasedUnitPrice = item.ProposedUnitPrice, PurchasedQuantity = item.Quantity, StockItemTypeID= item.StockItemTypeID }; supplyItem.TotalSpent = supplyItem.PurchasedUnitPrice * supplyItem.PurchasedQuantity; supplyItemBindingSource.Add(supplyItem); } }
// taking something takes up a turn private string Take(uint walkerId, uint fromWhere, SupplyItem what) { var pt = map.ResupplyPoints.FirstOrDefault(x => x.Id == fromWhere); if (pt == null) { return("the resupply point you've referred to doesn't exist"); } if (map.zombies.ContainsKey(walkerId)) { return("zombies can't use resupply points"); } if (!map.humans.ContainsKey(walkerId)) { return("your human has been removed from the game"); // walker isn't a human, or doesn't exist. } var w = map.humans[walkerId]; if (!w.IsCloseEnoughToInteractWith(pt)) { return("you're still too far away from the resupply point to interact with it"); // too far away to interact with this. } if (!pt.Available.Any(x => x == what)) { return("the item you wanted to take isn't at this resupply point"); // the desired item doesn't exist here. } if (w.InventoryIsFull) { return("your inventory is already full"); } bool taken = false; map.SetMovementState(walkerId, MoveState.Stopped); Func <bool> act = () => { if (taken) { return(false); } w.AddItem(what); pt.Remove(what); taken = true; return(false); }; ongoing[walkerId] = act; return(null); }
public async Task <IHttpActionResult> PostSupplyItems(List <SupplyItemProductViewModel> supplyItems, Guid supplyGuid) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var stockController = new StocksController(); //create the Supplyitems and link them to the Supply foreach (var p in supplyItems) { var supplyItem = new SupplyItem { SupplyItemGuid = Guid.NewGuid(), SupplyItemSupply = _db.Supplys.FirstOrDefault(g => g.SupplyGuid == supplyGuid), SupplyItemStockItem = _db.StockItems.FirstOrDefault(g => g.StockItemProduct.ProductGuid == p.ProductGuid), SupplyQuantity = p.SupplyQuantity }; _db.SupplyItems.Add(supplyItem); try { await _db.SaveChangesAsync(); } catch (DbUpdateException) { } await stockController.CreateStockTransaction(new StockItemViewModel { StockItemGuid = supplyItem.SupplyItemStockItem.StockItemGuid, StockItemQuantity = supplyItem.SupplyQuantity, Supply = supplyItem.SupplyItemSupply, Order = null }); } return(CreatedAtRoute("DefaultApi", new { id = supplyItems }, supplyItems)); }
public static SupplyItem Supply(Supply supply) { var result = new SupplyItem { Id = supply.SupplierId.ToString(), City = supply.City, CountryCode = supply.CountryCode, CreateDate = supply.CreateDate, FlatNumber = supply.FlatNumber, HouseNumber = supply.HouseNumber, Positions = ObjectMapper.Position(supply.Positions.ToList()), PostalCode = supply.PostalCode, Street = supply.Street, SupplierId = supply.SupplierId, SupplyNumber = supply.SupplyNumber, SupplyStatus = supply.SupplyStatus }; return(result); }
public void UpdateSupplyItem(SupplyItem supplyItem) { }
internal bool RemoveItem(SupplyItem what) { return(items.Remove(what)); }
public AddToSupplyRoom(SupplyItem item) { _item = item; }
ResupplyPoint GetClosestResupplyWith(IHumanPlayer player, List <ResupplyPoint> resupply, SupplyItem what) { return(resupply.OrderBy(x => x.DistanceFrom(player)).Where(x => x.Available.Contains(what)).FirstOrDefault()); }
public SupplyItem AddProductToSupplyQueue(SupplyItem item) { return(_SupplyRepository.AddProductToSupplyQueue(item)); }
public static SupplyResponse MapToResponse(this SupplyItem model) => new SupplyResponse() { Product = model.Product };
public SupplyItem AddSupplyItem(SupplyItem item) { _dataBaseContext.SupplyItems.AddObject(item); SaveChangesToDataBase(); return item; }
internal void Remove(SupplyItem item) { // there might be a game-semantics race-condition bug here. I probably don't care enough to fix it :). // If it gets horribly abused, maybe I should start caring... stored.Remove(item); }
private void button_Add_Click(object sender, EventArgs e) { if (SelectedPurchaseItem == null || textEdit_PurchasedQty.EditValue== null || textEdit_UnitPurchasePrice.EditValue == null) return; if (SupplyItems.Any(item => item.PurchaseItemID == SelectedPurchaseItem.PurchaseItemID)) { BuzzleFunctions.ShowMessage("The item is already on the list", "Duplicate item"); return; } var supplyItem = new SupplyItem() { PurchaseItemID = SelectedPurchaseItem.PurchaseItemID, PurchasedUnitPrice = int.Parse(textEdit_UnitPurchasePrice.EditValue.ToString()), PurchasedQuantity = int.Parse(textEdit_PurchasedQty.EditValue.ToString()), StockItemTypeID = SelectedPurchaseItem.StockItemTypeID }; supplyItem.TotalSpent = supplyItem.PurchasedUnitPrice*supplyItem.PurchasedQuantity; supplyItemBindingSource.Add(supplyItem); }