コード例 #1
0
ファイル: SupplyService.cs プロジェクト: mandocaesar/Animart
 public string CategoryToName(SupplyItem item)
 {
     if (item.CategoryId != null)
     {
         var data = _categoryRepository.FirstOrDefault(i => i.Id == item.CategoryId);
         return data.Name;
     }
     return "";
 }
コード例 #2
0
 public SupplyItem AddProductToSupplyQueue(SupplyItem item)
 {
     _applicationContext.SupplyQueue.Add(item);
     try
     {
         _applicationContext.SaveChanges();
         return(item);
     }
     catch (InvalidDataException e)
     {
         Console.WriteLine(e.Message);
         throw;
     }
 }
コード例 #3
0
ファイル: ProcessPurchaseView.cs プロジェクト: titusxp/buzzle
 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);
     }
 }
コード例 #4
0
        // 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);
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        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);
        }
コード例 #7
0
 public void UpdateSupplyItem(SupplyItem supplyItem)
 {
 }
コード例 #8
0
 internal bool RemoveItem(SupplyItem what)
 {
     return(items.Remove(what));
 }
コード例 #9
0
 public AddToSupplyRoom(SupplyItem item)
 {
     _item = item;
 }
コード例 #10
0
 ResupplyPoint GetClosestResupplyWith(IHumanPlayer player, List <ResupplyPoint> resupply, SupplyItem what)
 {
     return(resupply.OrderBy(x => x.DistanceFrom(player)).Where(x => x.Available.Contains(what)).FirstOrDefault());
 }
コード例 #11
0
 public SupplyItem AddProductToSupplyQueue(SupplyItem item)
 {
     return(_SupplyRepository.AddProductToSupplyQueue(item));
 }
コード例 #12
0
 public static SupplyResponse MapToResponse(this SupplyItem model)
 => new SupplyResponse()
 {
     Product = model.Product
 };
コード例 #13
0
ファイル: DataManager.cs プロジェクト: titusxp/buzzle
 public SupplyItem AddSupplyItem(SupplyItem item)
 {
     _dataBaseContext.SupplyItems.AddObject(item);
     SaveChangesToDataBase();
     return item;
 }
コード例 #14
0
 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);
 }
コード例 #15
0
ファイル: ProcessPurchaseView.cs プロジェクト: titusxp/buzzle
        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);
        }