private static void RealPrint(Person person) { ServiceProject.ServiceCardClient client = new ServiceProject.ServiceCardClient(); PrintType printTypeSpec = null; while (printTypeSpec == null) { Console.WriteLine("Choose what you want to print : "); DisplayQuotas(); string printChoice = Console.ReadLine(); int printChoiceInt = Int32.Parse(printChoice); printTypeSpec = client.GetPrintTypeById(printChoiceInt); } Console.WriteLine("How much of these you want to print ?"); string numberOfCopies = Console.ReadLine(); int numberOfCopiesInt = Int32.Parse(numberOfCopies); int result = client.Print(printTypeSpec.Id, person.Id, numberOfCopiesInt); if (result == 0) { Console.WriteLine("Payment failure : You don't have enough money"); Console.WriteLine($"You have tried to print {numberOfCopiesInt} {printTypeSpec.Description} {printTypeSpec.Color} {printTypeSpec.RectoVerso} for CHF {printTypeSpec.Price * numberOfCopiesInt}.- to {person.FirstName} {person.LastName}"); Console.WriteLine($"Actual balance : CHF {person.Balance}.-"); } else { person = client.GetPersonById(person.Id); Console.WriteLine($"You have just printed {numberOfCopiesInt} {printTypeSpec.Description} {printTypeSpec.Color} {printTypeSpec.RectoVerso} for CHF {printTypeSpec.Price * numberOfCopiesInt}.- to {person.FirstName} {person.LastName}"); Console.WriteLine($"New balance : CHF {person.Balance}.- "); } }
private static void DisplayUsers() { ServiceProject.ServiceCardClient client = new ServiceProject.ServiceCardClient(); var persons = client.GetAllPerson(); foreach (var person in persons) { Console.WriteLine(person.Id + "\t" + person.FirstName + "\t " + person.LastName + " \t" + person.Username + "\t CHF " + person.Balance + ".-"); } }
private static void DisplayQuotas() { ServiceProject.ServiceCardClient client = new ServiceProject.ServiceCardClient(); var printTypes = client.GetAllPrintType(); foreach (var printType in printTypes) { Console.WriteLine(""); Console.WriteLine(printType.Id + "\t" + printType.Description + " \t " + printType.Color + "\t" + printType.RectoVerso + "\t CHF " + printType.Price + ".-"); } }
private static void RealAddMoney(Person person) { ServiceProject.ServiceCardClient client = new ServiceProject.ServiceCardClient(); Console.WriteLine("How much money do you want to add to this user ?"); string amount = Console.ReadLine(); double amountDouble = Double.Parse(amount); client.AddMoneyToCard(person.Id, amountDouble); person = client.GetPersonById(person.Id); Console.WriteLine($"New balance : CHF {person.Balance}.- "); }
private static Person GetUserByUserId() { ServiceProject.ServiceCardClient client = new ServiceProject.ServiceCardClient(); Person person = null; while (person == null) { Console.WriteLine("Insert User ID :"); string userID = Console.ReadLine(); int userIdInt = Int32.Parse(userID); person = client.GetPersonById(userIdInt); } Console.WriteLine($"Person Username {person.Username} and ID {person.Id}: {person.LastName} {person.FirstName}"); Console.WriteLine($"Actual balance : CHF {person.Balance}.-"); return(person); }
static void Main(string[] args) { ServiceProject.ServiceCardClient client = new ServiceProject.ServiceCardClient(); Console.WriteLine("Database Management starting..."); Console.WriteLine("Database Management successfully started !"); Console.WriteLine(""); Console.WriteLine("List of the users : "); //Voir la liste des utilisateurs au démarrage DisplayUsers(); TaskChoice(); Console.WriteLine("Out of the program"); Console.ReadKey(); }
private static void Print() { ServiceProject.ServiceCardClient client = new ServiceProject.ServiceCardClient(); int response = ChooseUserIDorUsername(); //Via UserID if (response == 1) { Person person = GetUserByUserId(); RealPrint(person); } //Via Username if (response == 2) { Person person = GetUserByUsername(); RealPrint(person); } }
private static void RealAddQuotas(Person person) { ServiceProject.ServiceCardClient client = new ServiceProject.ServiceCardClient(); PrintType printTypeSpec = null; while (printTypeSpec == null) { Console.WriteLine("Choose which quotas you want to add ?"); DisplayQuotas(); string quotaChoice = Console.ReadLine(); int quotaChoiceInt = Int32.Parse(quotaChoice); printTypeSpec = client.GetPrintTypeById(quotaChoiceInt); } Console.WriteLine("How much of this quotas do you want to add? "); string numberOfCopies = Console.ReadLine(); int numberOfCopiesInt = Int32.Parse(numberOfCopies); client.AddMoneyToCard(person.Id, printTypeSpec.Price * numberOfCopiesInt); Person personRefresh = client.GetPersonById(person.Id); Console.WriteLine($"You have just added {numberOfCopiesInt} {printTypeSpec.Description} {printTypeSpec.Color} {printTypeSpec.RectoVerso} for CHF {printTypeSpec.Price * numberOfCopiesInt}.- to {personRefresh.FirstName} {personRefresh.LastName}"); Console.WriteLine($"New balance : CHF {personRefresh.Balance}.- "); }