internal static void SetVat(SiteAdministrator SA) { Console.WriteLine("Current VAT is:" + SA.Vat + "%"); Console.WriteLine("Please Enter new VAT:"); //Write to data store string path = Directory.GetCurrentDirectory() + "/VAT.txt".ToString(); System.IO.File.WriteAllText(path, Console.ReadLine().ToString()); // Assign new value to obj prop SA.Vat = Convert.ToDecimal(System.IO.File.ReadAllText(Directory.GetCurrentDirectory() + "/VAT.txt")); Console.WriteLine("The new VAT is: " + SA.Vat + "%"); Console.WriteLine("Log out as Site Administrator? y/n"); if (Console.ReadLine().ToString().ToLower() == "n") { Reset(SA); } else { Quit(SA); } }
static void SelectUser(string value) { string[] ValidCmds = new String[] { "reset", "quit", "donor", "sa", "options" }; var q = from cmds in ValidCmds where cmds == value select cmds; if (q.Contains(value)) { switch (value.ToLower()) { case "reset": Reset(); break; case "quit": Quit(); break; case "donor": Donor D = new Donor(); DonorCalculator.SetDonationAmount(D); Console.WriteLine("Quit application? y/n"); if (Console.ReadLine().ToLower().ToString() == "y") { Quit(); } else { Reset(); } break; case "sa": SiteAdministrator SA = new SiteAdministrator(); SiteAdministration.SetVat(SA); Console.WriteLine("Quit application? y/n"); if (Console.ReadLine().ToLower().ToString() == "y") { Quit(); } else { Reset(); } break; case "options": Console.WriteLine( Console.Out.NewLine + "This is the Gift Aid Calculator. You can use this appplication by typing your username. See below for list of options:" + Console.Out.NewLine + "Type 'Donor' to make a donation" + Console.Out.NewLine + "Type 'SA' to administrate the application" + Console.Out.NewLine + "Type 'Quit' to quit application" + Console.Out.NewLine ); goto case "reset"; } } else { Console.WriteLine("This is not a valid command."); Reset(); } }
public static void Reset(SiteAdministrator SA) { SetVat(SA); }
public static SiteAdministrator Quit(SiteAdministrator SA) { return SA; }