public string Run(RequestSender requestSender, ILoggerService log) { string welcome = " Remove Clients service."; log.Info(welcome); Console.WriteLine(welcome); // signal about enter into case int clientId = 0; string inputString = string.Empty; while (inputString != "e") { if (clientId == 0) { Console.Write(" Enter the Id of client for del: "); inputString = Console.ReadLine(); log.Info($"Id of client for del input: {inputString}"); int inputInt; int.TryParse(inputString, out inputInt); if (!StockExchangeValidation.checkId(inputInt)) { continue; } clientId = inputInt; } break; } if (inputString == "e") { string exitString = "Exit from Remove Clients service"; log.Info(exitString); return(exitString); } Console.WriteLine(" Wait a few seconds, please."); var reqResult = requestSender.RemoveClient(clientId); log.Info($"Request result: {reqResult}."); if (string.IsNullOrWhiteSpace(reqResult)) { return($" Client with Id = {clientId} was removed! Press Enter."); } return("Error. Client wasn't removed! Press Enter."); }
public string Run(RequestSender requestSender, ILoggerService log) { string welcome = " Edit Share info service"; log.Info(welcome); Console.WriteLine(welcome); // signal about enter into case int id = 0, shareTypeId = 0; string companyName = string.Empty; string inputString = string.Empty; while (inputString != "e") { if (id == 0) { Console.Write(" Enter the Id of share: "); inputString = Console.ReadLine(); log.Info($"Id of share input: {inputString}"); int inputInt; int.TryParse(inputString, out inputInt); if (!StockExchangeValidation.checkId(inputInt)) { continue; } id = inputInt; } if (string.IsNullOrEmpty(companyName)) { Console.Write(" Enter the Company name: "); inputString = Console.ReadLine(); log.Info($"Company name input: {inputString}"); if (!StockExchangeValidation.checkCompanyName(inputString)) { continue; } companyName = inputString; } if (shareTypeId == 0) { Console.Write(" Enter the Id of share type: "); inputString = Console.ReadLine(); log.Info($"Id of share type input: {inputString}"); int inputInt; int.TryParse(inputString, out inputInt); if (!StockExchangeValidation.checkId(inputInt)) { continue; } shareTypeId = inputInt; } break; } if (inputString == "e") { string exitString = "Exit from Edit Share info service"; log.Info(exitString); return(exitString); } Console.WriteLine(" Wait a few seconds, please."); var shareInputData = new ShareInputData { Id = id, CompanyName = companyName, ShareTypeId = shareTypeId }; log.Info($"Created ShareInputData with Id = {id}, CompanyName = { companyName}, ShareTypeId = { shareTypeId}"); var reqResult = requestSender.EditShare(shareInputData); log.Info($"Request result: {reqResult}."); if (string.IsNullOrWhiteSpace(reqResult)) { return($"Share with Id = {id} was changed! Press Enter."); } return("Error. Share wasn't changed! Press Enter."); }
public string Run(RequestSender requestSender, ILoggerService log) { string welcome = " Reports service - operations"; log.Info(welcome); Console.WriteLine(welcome); // signal about enter into case int clientId = 0; int top = 0; string inputString = string.Empty; while (inputString != "e") { if (clientId == 0) { Console.Write(" Enter the Id of client: "); inputString = Console.ReadLine(); log.Info($"Id of client input: {inputString}"); int inputInt; int.TryParse(inputString, out inputInt); if (!StockExchangeValidation.checkId(inputInt)) { continue; } clientId = inputInt; } if (top == 0) { Console.Write(" Enter the number of operations for view: "); inputString = Console.ReadLine(); log.Info($"Number of operations for view input: {inputString}"); int inputInt; int.TryParse(inputString, out inputInt); if (!StockExchangeValidation.checkId(inputInt)) { continue; } top = inputInt; } break; } if (inputString == "e") { return("Exit from Reports service - operations"); } Console.WriteLine(" Wait a few seconds, please."); var reqResult = requestSender.GetClientOperations(clientId, top); if (reqResult != null) { StringBuilder operationString; foreach (var operation in reqResult) { operationString = new StringBuilder(); operationString.Append($"Id: {operation.Id}\n"); operationString.Append($" Debit Date: {operation.DebitDate}\n"); operationString.Append($" Customer Id: {operation.Customer.Id}\n"); operationString.Append($" Charge Date: {operation.ChargeDate}\n"); operationString.Append($" Seller Id: {operation.Seller.Id}\n"); operationString.Append($" Share Id: {operation.Share.Id}\n"); operationString.Append($" Share Type Name: {operation.ShareTypeName}\n"); operationString.Append($" Cost: {operation.Cost}\n"); operationString.Append($" Number: {operation.Number}\n"); operationString.Append($" Total: {operation.Total}"); Console.WriteLine(operationString.ToString()); log.Info(operationString.ToString()); } return($"List of operations for clientId = {clientId}"); } log.Info("Error. Client wasn't found!"); return("Error. Client wasn't found! Press Enter."); }
public string Run(RequestSender requestSender, ILoggerService log) { string welcome = " Edit Clients info service."; log.Info(welcome); Console.WriteLine(welcome); // signal about enter into case int id = 0; string lastName = string.Empty, firstName = string.Empty, phoneNumber = string.Empty; string inputString = string.Empty; while (inputString != "e") { if (id == 0) { Console.Write(" Enter the Id of client: "); inputString = Console.ReadLine(); log.Info($"Id of client input: {inputString}"); int inputInt; int.TryParse(inputString, out inputInt); if (!StockExchangeValidation.checkId(inputInt)) { continue; } id = inputInt; } if (string.IsNullOrEmpty(lastName)) { Console.Write(" Enter the Last name of client: "); inputString = Console.ReadLine(); log.Info($"Last name input: {inputString}"); if (!StockExchangeValidation.checkClientLastName(inputString)) { continue; } lastName = inputString; } if (string.IsNullOrEmpty(firstName)) { Console.Write(" Enter the First name of client: "); inputString = Console.ReadLine(); log.Info($"First name input: {inputString}"); if (!StockExchangeValidation.checkClientFirstName(inputString)) { continue; } firstName = inputString; } if (string.IsNullOrEmpty(phoneNumber)) { Console.Write(" Enter the phone number of client: "); inputString = Console.ReadLine(); log.Info($"Phone number input: {inputString}"); if (!StockExchangeValidation.checkClientPhoneNumber(inputString)) { continue; } phoneNumber = inputString; } break; } if (inputString == "e") { string exitString = "Exit from registration"; log.Info(exitString); return(exitString); } Console.WriteLine(" Wait a few seconds, please."); var clientInputData = new ClientInputData { Id = id, LastName = lastName, FirstName = firstName, PhoneNumber = phoneNumber }; log.Info($"Created ClientInputData with Id = {id}, LastName = {lastName}, FirstName = { firstName}, PhoneNumber = { phoneNumber}"); var reqResult = requestSender.EditClient(clientInputData); log.Info($"Request result: {reqResult}."); if (string.IsNullOrWhiteSpace(reqResult)) { return($" Client with Id = {id} was changed! Press Enter."); } return("Error. Client wasn't edited! Press Enter."); }
public string Run(RequestSender requestSender, ILoggerService log) { string welcome = " Clients registration service."; log.Info(welcome); Console.WriteLine(welcome); // signal about enter into case string lastName = string.Empty, firstName = string.Empty, phoneNumber = string.Empty; decimal moneyAmount = 0; string inputString = string.Empty; while (inputString != "e") { if (string.IsNullOrEmpty(lastName)) { Console.Write(" Enter the Last name of client: "); inputString = Console.ReadLine(); log.Info($"Last Name input: {inputString}"); if (!StockExchangeValidation.checkClientLastName(inputString)) { continue; } lastName = inputString; } if (string.IsNullOrEmpty(firstName)) { Console.Write(" Enter the First name of client: "); inputString = Console.ReadLine(); log.Info($"First Name input: {inputString}"); if (!StockExchangeValidation.checkClientFirstName(inputString)) { continue; } firstName = inputString; } if (string.IsNullOrEmpty(phoneNumber)) { Console.Write(" Enter the phone number of client: "); inputString = Console.ReadLine(); log.Info($"Phone number input: {inputString}"); if (!StockExchangeValidation.checkClientPhoneNumber(inputString)) { continue; } phoneNumber = inputString; } if (moneyAmount == 0) { Console.Write(" Enter the money amount of client: "); inputString = Console.ReadLine(); log.Info($"Money amount input: {inputString}"); decimal inputDecimal; decimal.TryParse(inputString, out inputDecimal); if (!StockExchangeValidation.checkClientBalanceAmount(inputDecimal)) { continue; } moneyAmount = inputDecimal; } break; } if (inputString == "e") { string exitString = "Exit from registration"; log.Info(exitString); return(exitString); } Console.WriteLine(" Wait a few seconds, please."); var clientInputData = new ClientInputData { LastName = lastName, FirstName = firstName, PhoneNumber = phoneNumber, Amount = moneyAmount }; log.Info($"Created ClientInputData with LastName = {lastName}, FirstName = { firstName}, PhoneNumber = { phoneNumber}, Amount = { moneyAmount}"); var reqResult = requestSender.AddClient(clientInputData); log.Info($"Request result: {reqResult}."); if (string.IsNullOrWhiteSpace(reqResult)) { return("New client was added! Press Enter."); } return("Error. Client wasn't added! Press Enter."); }