public void Delete() { // Returns first element called Nokia to database CompanyAsset assetDelete = _assetTrackorContext.CompanyAssets.Where(asset => asset.ModelName == "Nokia").FirstOrDefault(); _assetTrackorContext.CompanyAssets.Remove(assetDelete); _assetTrackorContext.SaveChanges(); }
public void Update() { // Returns first element that was added to database (Lowest ID), in this case MacBook CompanyAsset assetUpdate = _assetTrackorContext.CompanyAssets.FirstOrDefault(); assetUpdate.Office = "Sweden"; _assetTrackorContext.SaveChanges(); }
static void WriteItemToConsole(CompanyAsset item, string price) { if (price == "") { // Convert CompanyAsset price to a string price = item.Price.ToString(); } Console.WriteLine( item.AssetType.PadRight(10) + " " + item.ModelName.PadRight(11) + price.PadLeft(14) + " " + item.PurchaseDate.ToString("MM/dd/yyyy").PadRight(10) + " " + item.Office.PadRight(10)); }