Implemented ConsoleMenu further
This commit is contained in:
@@ -183,7 +183,6 @@ namespace WD7UVN_HFT_2023241.Client
|
|||||||
menu.Add($"{c.NAME}: {c.ID}", () => RESTEmployee(c.ID));
|
menu.Add($"{c.NAME}: {c.ID}", () => RESTEmployee(c.ID));
|
||||||
}
|
}
|
||||||
menu.Add("Back", ConsoleMenu.Close);
|
menu.Add("Back", ConsoleMenu.Close);
|
||||||
menu.Add("Exit", () => Environment.Exit(0));
|
|
||||||
menu.Show();
|
menu.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,8 +322,6 @@ namespace WD7UVN_HFT_2023241.Client
|
|||||||
public class Create
|
public class Create
|
||||||
{
|
{
|
||||||
public static void Customer()
|
public static void Customer()
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -353,20 +350,14 @@ namespace WD7UVN_HFT_2023241.Client
|
|||||||
};
|
};
|
||||||
|
|
||||||
RestService.Put<Customer>(c, "/api/Customer/");
|
RestService.Put<Customer>(c, "/api/Customer/");
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
catch (FormatException)
|
catch (FormatException)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Invalid format!");
|
Console.WriteLine("Invalid format!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static void Employee()
|
public static void Employee()
|
||||||
{
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -399,20 +390,14 @@ namespace WD7UVN_HFT_2023241.Client
|
|||||||
};
|
};
|
||||||
|
|
||||||
RestService.Put<Employee>(c, "/api/Employee/");
|
RestService.Put<Employee>(c, "/api/Employee/");
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
catch (FormatException)
|
catch (FormatException)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Invalid format!");
|
Console.WriteLine("Invalid format!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static void Service()
|
public static void Service()
|
||||||
{
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -457,20 +442,14 @@ namespace WD7UVN_HFT_2023241.Client
|
|||||||
};
|
};
|
||||||
|
|
||||||
RestService.Put<Service>(c, "/api/Service/");
|
RestService.Put<Service>(c, "/api/Service/");
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
catch (FormatException)
|
catch (FormatException)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Invalid format!");
|
Console.WriteLine("Invalid format!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static void MaintainerTeam()
|
public static void MaintainerTeam()
|
||||||
{
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -495,37 +474,20 @@ namespace WD7UVN_HFT_2023241.Client
|
|||||||
};
|
};
|
||||||
|
|
||||||
RestService.Put<MaintainerTeam>(c, "/api/MaintainerTeam/");
|
RestService.Put<MaintainerTeam>(c, "/api/MaintainerTeam/");
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
catch (FormatException)
|
catch (FormatException)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Invalid format!");
|
Console.WriteLine("Invalid format!");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Update
|
public class Update
|
||||||
{
|
{
|
||||||
public static void Customer()
|
private static void RESTCustomer(int id)
|
||||||
{
|
{
|
||||||
int input;
|
Customer c = RestService.Get<Customer>(id, "/api/Customer/");
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Console.Write("Enter a number for the customer's ID: ");
|
|
||||||
input = Convert.ToInt32(Console.ReadLine());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
catch (FormatException)
|
|
||||||
{
|
|
||||||
Console.WriteLine("You must enter a number.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Customer c = RestService.Get<Customer>(input, "/api/Customer/");
|
|
||||||
|
|
||||||
Console.WriteLine("Name: " + c.NAME);
|
Console.WriteLine("Name: " + c.NAME);
|
||||||
Console.WriteLine("Email: " + c.EMAIL);
|
Console.WriteLine("Email: " + c.EMAIL);
|
||||||
@@ -552,7 +514,7 @@ namespace WD7UVN_HFT_2023241.Client
|
|||||||
|
|
||||||
c = new Customer()
|
c = new Customer()
|
||||||
{
|
{
|
||||||
ID = input,
|
ID = id,
|
||||||
NAME = name,
|
NAME = name,
|
||||||
EMAIL = email,
|
EMAIL = email,
|
||||||
PHONE = phone,
|
PHONE = phone,
|
||||||
@@ -568,29 +530,22 @@ namespace WD7UVN_HFT_2023241.Client
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static void Customer()
|
||||||
public static void Employee()
|
|
||||||
{
|
{
|
||||||
|
var menu = new ConsoleMenu();
|
||||||
int input;
|
foreach (Customer c in RestService.Get<Customer>("/api/Customer/"))
|
||||||
while (true)
|
|
||||||
{
|
{
|
||||||
try
|
menu.Add($"{c.NAME}: {c.ID}", () => RESTCustomer(c.ID));
|
||||||
{
|
|
||||||
Console.Write("Enter a number for the employee's ID: ");
|
|
||||||
input = Convert.ToInt32(Console.ReadLine());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
catch (FormatException)
|
|
||||||
{
|
|
||||||
Console.WriteLine("You must enter a number.");
|
|
||||||
}
|
}
|
||||||
|
menu.Add("Back", ConsoleMenu.Close);
|
||||||
|
menu.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
Employee c = RestService.Get<Employee>(input, "/api/Employee/");
|
private static void RESTEmployee(int id)
|
||||||
|
{
|
||||||
|
Employee c = RestService.Get<Employee>(id, "/api/Employee/");
|
||||||
|
|
||||||
Console.WriteLine("Name: " + c.NAME);
|
Console.WriteLine("Name: " + c.NAME);
|
||||||
Console.WriteLine("ID: " + c.ID);
|
|
||||||
Console.WriteLine("Email: " + c.EMAIL);
|
Console.WriteLine("Email: " + c.EMAIL);
|
||||||
Console.WriteLine("Phone: " + c.PHONE);
|
Console.WriteLine("Phone: " + c.PHONE);
|
||||||
Console.WriteLine("Maintainer team's ID: " + c.MAINTAINER_ID);
|
Console.WriteLine("Maintainer team's ID: " + c.MAINTAINER_ID);
|
||||||
@@ -619,7 +574,7 @@ namespace WD7UVN_HFT_2023241.Client
|
|||||||
|
|
||||||
c = new Employee()
|
c = new Employee()
|
||||||
{
|
{
|
||||||
ID = input,
|
ID = id,
|
||||||
NAME = name,
|
NAME = name,
|
||||||
EMAIL = email,
|
EMAIL = email,
|
||||||
PHONE = phone,
|
PHONE = phone,
|
||||||
@@ -636,26 +591,20 @@ namespace WD7UVN_HFT_2023241.Client
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static void Employee()
|
||||||
public static void Service()
|
|
||||||
{
|
{
|
||||||
|
var menu = new ConsoleMenu();
|
||||||
int input;
|
foreach (Employee c in RestService.Get<Employee>("/api/Employee/"))
|
||||||
while (true)
|
|
||||||
{
|
{
|
||||||
try
|
menu.Add($"{c.NAME}: {c.ID}", () => RESTEmployee(c.ID));
|
||||||
{
|
|
||||||
Console.Write("Enter a number for the service's ID: ");
|
|
||||||
input = Convert.ToInt32(Console.ReadLine());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
catch (FormatException)
|
|
||||||
{
|
|
||||||
Console.WriteLine("You must enter a number.");
|
|
||||||
}
|
}
|
||||||
|
menu.Add("Back", ConsoleMenu.Close);
|
||||||
|
menu.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
Service c = RestService.Get<Service>(input, "/api/Service/");
|
private static void RESTService(int id)
|
||||||
|
{
|
||||||
|
Service c = RestService.Get<Service>(id, "/api/Service/");
|
||||||
|
|
||||||
Console.WriteLine("Name: " + c.NAME);
|
Console.WriteLine("Name: " + c.NAME);
|
||||||
Console.WriteLine("ID: " + c.ID);
|
Console.WriteLine("ID: " + c.ID);
|
||||||
@@ -666,6 +615,7 @@ namespace WD7UVN_HFT_2023241.Client
|
|||||||
Console.WriteLine("Service domain: " + c.SERVICE_DOMAIN);
|
Console.WriteLine("Service domain: " + c.SERVICE_DOMAIN);
|
||||||
Console.WriteLine("Version: " + c.VERSION);
|
Console.WriteLine("Version: " + c.VERSION);
|
||||||
Console.WriteLine("Maintainer team's ID: " + c.MAINTAINER_ID);
|
Console.WriteLine("Maintainer team's ID: " + c.MAINTAINER_ID);
|
||||||
|
|
||||||
Console.WriteLine("Now you can modify these fields, except for the ID.");
|
Console.WriteLine("Now you can modify these fields, except for the ID.");
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
@@ -698,7 +648,7 @@ namespace WD7UVN_HFT_2023241.Client
|
|||||||
|
|
||||||
c = new Service()
|
c = new Service()
|
||||||
{
|
{
|
||||||
ID = input,
|
ID = id,
|
||||||
NAME = name,
|
NAME = name,
|
||||||
MAINTAINER_ID = maintainer_id,
|
MAINTAINER_ID = maintainer_id,
|
||||||
PORT = port,
|
PORT = port,
|
||||||
@@ -718,26 +668,20 @@ namespace WD7UVN_HFT_2023241.Client
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static void Service()
|
||||||
public static void MaintainerTeam()
|
|
||||||
{
|
{
|
||||||
|
var menu = new ConsoleMenu();
|
||||||
int input;
|
foreach (Service c in RestService.Get<Service>("/api/Service/"))
|
||||||
while (true)
|
|
||||||
{
|
{
|
||||||
try
|
menu.Add($"{c.NAME}: {c.ID}", () => RESTService(c.ID));
|
||||||
{
|
|
||||||
Console.Write("Enter a number for the service's ID: ");
|
|
||||||
input = Convert.ToInt32(Console.ReadLine());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
catch (FormatException)
|
|
||||||
{
|
|
||||||
Console.WriteLine("You must enter a number.");
|
|
||||||
}
|
}
|
||||||
|
menu.Add("Back", ConsoleMenu.Close);
|
||||||
|
menu.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
MaintainerTeam c = RestService.Get<MaintainerTeam>(input, "/api/MaintainerTeam/");
|
private static void RESTMaintainerTeam(int id)
|
||||||
|
{
|
||||||
|
MaintainerTeam c = RestService.Get<MaintainerTeam>(id, "/api/MaintainerTeam/");
|
||||||
|
|
||||||
Console.WriteLine("Name: " + c.NAME);
|
Console.WriteLine("Name: " + c.NAME);
|
||||||
Console.WriteLine("ID: " + c.ID);
|
Console.WriteLine("ID: " + c.ID);
|
||||||
@@ -761,7 +705,7 @@ namespace WD7UVN_HFT_2023241.Client
|
|||||||
|
|
||||||
c = new MaintainerTeam()
|
c = new MaintainerTeam()
|
||||||
{
|
{
|
||||||
ID = input,
|
ID = id,
|
||||||
NAME = name,
|
NAME = name,
|
||||||
LEADER_ID = leader_id,
|
LEADER_ID = leader_id,
|
||||||
EMAIL = email
|
EMAIL = email
|
||||||
@@ -776,6 +720,16 @@ namespace WD7UVN_HFT_2023241.Client
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static void MaintainerTeam()
|
||||||
|
{
|
||||||
|
var menu = new ConsoleMenu();
|
||||||
|
foreach (MaintainerTeam c in RestService.Get<MaintainerTeam>("/api/MaintainerTeam/"))
|
||||||
|
{
|
||||||
|
menu.Add($"{c.NAME}: {c.ID}", () => RESTMaintainerTeam(c.ID));
|
||||||
|
}
|
||||||
|
menu.Add("Back", ConsoleMenu.Close);
|
||||||
|
menu.Show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Delete
|
public class Delete
|
||||||
@@ -786,11 +740,15 @@ namespace WD7UVN_HFT_2023241.Client
|
|||||||
{
|
{
|
||||||
RestService.Delete(id, "/api/Customer/");
|
RestService.Delete(id, "/api/Customer/");
|
||||||
Console.WriteLine("Successfully deleted Customer with ID {0}", id);
|
Console.WriteLine("Successfully deleted Customer with ID {0}", id);
|
||||||
|
Console.WriteLine("Press any key to continue.");
|
||||||
|
Console.ReadKey();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Uh-oh...");
|
Console.WriteLine("The following error occured:");
|
||||||
Console.WriteLine(e.Message);
|
Console.WriteLine(e.Message);
|
||||||
|
Console.WriteLine("Press any key to continue.");
|
||||||
|
Console.ReadKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void Customer()
|
public static void Customer()
|
||||||
@@ -810,11 +768,15 @@ namespace WD7UVN_HFT_2023241.Client
|
|||||||
{
|
{
|
||||||
RestService.Delete(id, "/api/Employee/");
|
RestService.Delete(id, "/api/Employee/");
|
||||||
Console.WriteLine("Successfully deleted Employee with ID {0}", id);
|
Console.WriteLine("Successfully deleted Employee with ID {0}", id);
|
||||||
|
Console.WriteLine("Press any key to continue.");
|
||||||
|
Console.ReadKey();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Uh-oh...");
|
Console.WriteLine("The following error occured:");
|
||||||
Console.WriteLine(e.Message);
|
Console.WriteLine(e.Message);
|
||||||
|
Console.WriteLine("Press any key to continue.");
|
||||||
|
Console.ReadKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void Employee()
|
public static void Employee()
|
||||||
@@ -834,11 +796,15 @@ namespace WD7UVN_HFT_2023241.Client
|
|||||||
{
|
{
|
||||||
RestService.Delete(id, "/api/Service/");
|
RestService.Delete(id, "/api/Service/");
|
||||||
Console.WriteLine("Successfully deleted Service with ID {0}", id);
|
Console.WriteLine("Successfully deleted Service with ID {0}", id);
|
||||||
|
Console.WriteLine("Press any key to continue.");
|
||||||
|
Console.ReadKey();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Uh-oh...");
|
Console.WriteLine("The following error occured:");
|
||||||
Console.WriteLine(e.Message);
|
Console.WriteLine(e.Message);
|
||||||
|
Console.WriteLine("Press any key to continue.");
|
||||||
|
Console.ReadKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void Service()
|
public static void Service()
|
||||||
@@ -858,11 +824,15 @@ namespace WD7UVN_HFT_2023241.Client
|
|||||||
{
|
{
|
||||||
RestService.Delete(id, "/api/MaintainerTeam/");
|
RestService.Delete(id, "/api/MaintainerTeam/");
|
||||||
Console.WriteLine("Successfully deleted MaintainerTeam with ID {0}", id);
|
Console.WriteLine("Successfully deleted MaintainerTeam with ID {0}", id);
|
||||||
|
Console.WriteLine("Press any key to continue.");
|
||||||
|
Console.ReadKey();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Uh-oh...");
|
Console.WriteLine("The following error occured:");
|
||||||
Console.WriteLine(e.Message);
|
Console.WriteLine(e.Message);
|
||||||
|
Console.WriteLine("Press any key to continue.");
|
||||||
|
Console.ReadKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void MaintainerTeam()
|
public static void MaintainerTeam()
|
||||||
|
|||||||
Reference in New Issue
Block a user