// Assets value acording to category public int AddNewAssetBalanceView() { CustomerStatements.CallToAction(" Please choose Appropriate ASSET-CLASS for BALANCE"); CustomerStatements.CallToAction(" 1 for CRYPTOCURRENCY, 2 for STOCKS 3, 3 for REAL-ESTATES, 4 for OTHERS"); WrongKey: var assetId = Console.ReadKey(); int id; int.TryParse(assetId.KeyChar.ToString(), out id); switch (id) { case 1: break; case 2: break; case 3: break; case 4: break; default: Console.WriteLine(" - Wrong Key , Please choose again Appropiate ASSET=CLASS"); goto WrongKey; } return(id); }
// Removing Asset public int RemoveAssetView() { CustomerStatements.CallToAction(" Please enter id for item you want to remove"); var assetId = Console.ReadKey(); int id; Int32.TryParse(assetId.KeyChar.ToString(), out id); return(id); }
// Watching assets in particular categories public int AssetDetailSelectionView() { CustomerStatements.CallToAction(" Please enter id for asset you want to see"); Console.WriteLine( ); var assetId = Console.ReadKey(); int id; Int32.TryParse(assetId.KeyChar.ToString(), out id); return(id); }
public int AssetTypeSelectionView() { CustomerStatements.CallToAction(" Please enter asset Type for asset you want to see Press:"); CustomerStatements.CallToAction(" 1 for CRYPTOCURRENCY, 2 for STOCKS 3, 3 for REAL-ESTATES, 4 for OTHERS"); Console.WriteLine(); var assetId = Console.ReadKey(); int id; Int32.TryParse(assetId.KeyChar.ToString(), out id); return(id); }
//Financial Result public void FinancialResult() { decimal result = FullWalletValue() - MoneyInvested(); if (result > 0) { CustomerStatements.CallToAction($" Your total PROFIT is:{result}"); } else if (result < 0) { CustomerStatements.CallToAction($" Your total LOSS is:{result}"); } else { CustomerStatements.CallToAction($" Your NET result is 0"); } }
public ConsoleKeyInfo AddNewAssetView(MenuActionService actionService) { var addNewAssetMenu = actionService.GetMenuActionsByMenuName("AddNewAssetMenu"); Console.WriteLine(); CustomerStatements.CallToAction(" Please choose Appropriate ASSET-CLASS"); Console.WriteLine(); for (int i = 0; i < addNewAssetMenu.Count; i++) { Console.WriteLine("{0}. {1}", addNewAssetMenu[i].Id, addNewAssetMenu[i].Name); } WrongKey: var operation = Console.ReadKey(); switch (operation.KeyChar) { case '1': break; case '2': break; case '3': break; case '4': break; default: Console.WriteLine(); Console.WriteLine(" - Wrong Key , Please choose again Appropiate ASSET=CLASS"); Console.WriteLine(); goto WrongKey; } return(operation); }
public int AddNewAssets(char assetType) { int assetTypeId; Int32.TryParse(assetType.ToString(), out assetTypeId); Asset asset = new Asset(); asset.TypeId = assetTypeId; Console.WriteLine(); CustomerStatements.CallToAction(" Please enter id for new asset"); Console.WriteLine(); var id = Console.ReadLine(); int assetId; while (!Int32.TryParse(id, out assetId)) { Console.WriteLine("Id must be a number - try again"); Console.WriteLine(); id = Console.ReadLine(); } while (CheckID.Contains(assetId)) { CustomerStatements.CallToAction("This Id Asset is on the list, Please choose another Id"); Console.WriteLine(); id = Console.ReadLine(); Int32.TryParse(id, out assetId); } asset.Id = assetId; CheckID.Add(assetId); // dodaje do listy id by później sprawdzić czy się nie powtarza Console.WriteLine(); CustomerStatements.CallToAction(" Please enter name for new asset"); Console.WriteLine(); var assetName = Console.ReadLine(); asset.Name = assetName; Console.WriteLine(); CustomerStatements.CallToAction(" Please enter shortcut( for example 'BTC') for new asset"); Console.WriteLine(); var assetShortcut = Console.ReadLine(); asset.Shortcut = assetShortcut; Console.WriteLine(); CustomerStatements.CallToAction(" Please enter Placement (for example : name of exchange, cryptocurrency address, real estate address) for new asset"); Console.WriteLine(); var assetPlacement = Console.ReadLine(); asset.Placement = assetPlacement; Console.WriteLine(); CustomerStatements.CallToAction($" Please enter amount of {assetName} you have"); Console.WriteLine(); var amount = Console.ReadLine(); decimal assetAmount; while (!decimal.TryParse(amount, out assetAmount)) { Console.WriteLine(" Amount must be a number - try again!!"); Console.WriteLine(); amount = Console.ReadLine(); } asset.Amount = assetAmount; Console.WriteLine(); CustomerStatements.CallToAction($" Please enter Price ( in $) you bought {assetName} at"); Console.WriteLine(); var bought = Console.ReadLine(); decimal assetBought; while (!decimal.TryParse(bought, out assetBought)) { Console.WriteLine(); Console.WriteLine(" Amount must be a number - try again!!"); bought = Console.ReadLine(); } asset.InvestitionPrice = assetBought; Console.WriteLine(); CustomerStatements.CallToAction($" Please enter current Price ( in $) of {assetName}"); Console.WriteLine(); var price = Console.ReadLine(); decimal assetPrice; while (!decimal.TryParse(price, out assetPrice)) { Console.WriteLine(); Console.WriteLine(" Asset Price must be a number - try again!!"); price = Console.ReadLine(); } asset.CurrentPrice = assetPrice; // Checking Current Value of this asset decimal assetValue = assetAmount * assetPrice; asset.AssetValue = assetValue; // Checking how many invested in this asset decimal assetInvestet = assetAmount * assetBought; asset.InvestedMoney = assetInvestet; //Checking profit or loss with this asset decimal assetBalance = assetValue - assetInvestet; asset.AssetBalance = assetBalance; // Adding asset to Assets List Assets.Add(asset); return(assetId); }
static void Main(string[] args) { //Programm presentation CustomerStatements.DataAndTime(); CustomerStatements.Header("Welcome in AssetsManager", "This Program is a tool for managing your assets"); Console.ReadLine(); // New Objects of Our service MenuActionService actionService = new MenuActionService(); AssetService assetService = new AssetService(); // Menu actionService = Initialize(actionService); // tworzy wszystkie elementy menu których będę używać while (true) { CustomerStatements.CallToAction("There is main Menu. What would you like to do?:"); var mainMenu = actionService.GetMenuActionsByMenuName("Main"); for (int i = 0; i < mainMenu.Count; i++) { Console.WriteLine("{0}. {1}", mainMenu[i].Id, mainMenu[i].Name); } var operation = Console.ReadKey(); switch (operation.KeyChar) { case '1': Console.WriteLine(" ═══════════════════════════════════════════════════════════════════════════════════════"); var keyinfo = assetService.AddNewAssetView(actionService); var id = assetService.AddNewAssets(keyinfo.KeyChar); break; case '2': Console.WriteLine(" ═══════════════════════════════════════════════════════════════════════════════════════"); assetService.AllYourAssets(); Console.WriteLine(" ═══════════════════════════════════════════════════════════════════════════════════════"); break; case '3': Console.WriteLine(" ═══════════════════════════════════════════════════════════════════════════════════════"); var removeId = assetService.RemoveAssetView(); assetService.RemoveAsset(removeId); Console.WriteLine(" ═══════════════════════════════════════════════════════════════════════════════════════"); break; case '4': Console.WriteLine(" ═══════════════════════════════════════════════════════════════════════════════════════"); var detailId = assetService.AssetDetailSelectionView(); assetService.AssetDetailView(detailId); Console.WriteLine(" ═══════════════════════════════════════════════════════════════════════════════════════"); break; case '5': Console.WriteLine(" ═══════════════════════════════════════════════════════════════════════════════════════"); var assetId = assetService.AssetTypeSelectionView(); assetService.AssetsByAssetTypeView(assetId); Console.WriteLine(" ═══════════════════════════════════════════════════════════════════════════════════════"); break; case '6': Console.WriteLine(" ═══════════════════════════════════════════════════════════════════════════════════════"); assetService.FullWalletValue(); Console.WriteLine(" ═══════════════════════════════════════════════════════════════════════════════════════"); break; case '7': Console.WriteLine(" ═══════════════════════════════════════════════════════════════════════════════════════"); var balanceId = assetService.AddNewAssetBalanceView(); assetService.AddNewBalance(balanceId); Console.WriteLine(" ═══════════════════════════════════════════════════════════════════════════════════════"); break; case '8': Console.WriteLine(" ═══════════════════════════════════════════════════════════════════════════════════════"); assetService.MoneyInvested(); Console.WriteLine(" ═══════════════════════════════════════════════════════════════════════════════════════"); break; case '9': Console.WriteLine(" ═══════════════════════════════════════════════════════════════════════════════════════"); assetService.FinancialResult(); Console.WriteLine(" ═══════════════════════════════════════════════════════════════════════════════════════"); break; default: Console.WriteLine(); CustomerStatements.CallToAction("Nieprawidłowy klawisz , spróbuj ponownie"); break; } } }