public void ReadFile() { ItemCollection.Clear(); using (StreamReader reader = new StreamReader(File)) { var header = reader.ReadLine(); while (!reader.EndOfStream) { var data = reader.ReadLine(); var item = ItemModel.Create(header, data, ','); ItemCollection.Add(item); } } }
public ActionResult Create(FormCollection form) { ComandaEletronica.Entity.Item e = new Item(); //e.Id = int.Parse(form["id"]); e.Produto_Id = int.Parse(form["produto_id"]); e.Funcionario_Id = int.Parse(form["funcionario_id"]); e.Pedido_Id = int.Parse(form["pedido_id"]); e.Qtd = int.Parse(form["qtd"]); e.Preco = decimal.Parse(form["preco"]); e.DataEntrega = DateTime.Parse(form["dataEntrega"]); e.Status = StatusItem.Produzindo; using (ItemModel model = new ItemModel()) { model.Create(e); } return(RedirectToAction("Index")); }
/// <summary> /// Gives the character the specified item and quantity /// </summary> /// <param name="dbconn">The database connection</param> /// <param name="tableIndex">Table index of the item to give</param> /// <param name="quantity">The amount</param> /// <returns>InventoryItem on success, null on failure</returns> public InventoryItem GiveItem(MySqlConnection dbconn, int tableIndex, uint quantity) { var invIdx = InventoryItems.Count; /*int invIdx = 0; * foreach (var item in InventoryItems) * { * if (item == null) * break; * invIdx++; * }*/ var invItem = new InventoryItem(Id, ActiveVehicleId, tableIndex, (uint)invIdx, quantity); if (!ItemModel.Create(dbconn, invItem)) { return(null); } AddItemMod(invItem); InventoryItems.Add(invItem); return(invItem); }