Added new WPF client and accomodated folder structure
This commit is contained in:
@@ -1,265 +1,265 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Net.Security;
|
using System.Net.Security;
|
||||||
using WD7UVN_HFT_2023241.Models;
|
using WD7UVN_HFT_2023241.Models;
|
||||||
|
|
||||||
namespace WD7UVN_HFT_2023241.Client
|
namespace WD7UVN_HFT_2023241.Client.Shared
|
||||||
{
|
{
|
||||||
class RestService
|
public class RestService
|
||||||
{
|
{
|
||||||
private static HttpClient client;
|
private static HttpClient client;
|
||||||
|
|
||||||
private static bool Ping(string url)
|
private static bool Ping(string url)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; });
|
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; });
|
||||||
|
|
||||||
WebClient wc = new WebClient();
|
WebClient wc = new WebClient();
|
||||||
wc.DownloadData(url);
|
wc.DownloadData(url);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Init(string baseurl = "https://localhost:5001", string pingableEndpoint = "/swagger")
|
public static void Init(string baseurl = "https://localhost:5001", string pingableEndpoint = "/swagger")
|
||||||
{
|
{
|
||||||
int tries = 0;
|
int tries = 0;
|
||||||
bool isOk = false;
|
bool isOk = false;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
isOk = Ping(baseurl + pingableEndpoint);
|
isOk = Ping(baseurl + pingableEndpoint);
|
||||||
tries++;
|
tries++;
|
||||||
} while (isOk == false && tries < 5);
|
} while (isOk == false && tries < 5);
|
||||||
|
|
||||||
if (isOk == false)
|
if (isOk == false)
|
||||||
{
|
{
|
||||||
throw new EndpointNotAvailableException("Endpoint is not available!");
|
throw new EndpointNotAvailableException("Endpoint is not available!");
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpClientHandler handler = new HttpClientHandler();
|
HttpClientHandler handler = new HttpClientHandler();
|
||||||
handler.ClientCertificateOptions = ClientCertificateOption.Manual;
|
handler.ClientCertificateOptions = ClientCertificateOption.Manual;
|
||||||
handler.ServerCertificateCustomValidationCallback =
|
handler.ServerCertificateCustomValidationCallback =
|
||||||
(httpRequestMessage, cert, cetChain, policyErrors) =>
|
(httpRequestMessage, cert, cetChain, policyErrors) =>
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
client = new HttpClient(handler);
|
client = new HttpClient(handler);
|
||||||
client.BaseAddress = new Uri(baseurl);
|
client.BaseAddress = new Uri(baseurl);
|
||||||
client.DefaultRequestHeaders.Accept.Clear();
|
client.DefaultRequestHeaders.Accept.Clear();
|
||||||
client.DefaultRequestHeaders.Accept.Add(
|
client.DefaultRequestHeaders.Accept.Add(
|
||||||
new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue
|
new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue
|
||||||
("application/json"));
|
("application/json"));
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
client.GetAsync("").GetAwaiter().GetResult();
|
client.GetAsync("").GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
catch (HttpRequestException e)
|
catch (HttpRequestException e)
|
||||||
{
|
{
|
||||||
Console.WriteLine(e.Message);
|
Console.WriteLine(e.Message);
|
||||||
throw new ArgumentException("Endpoint is not available!");
|
throw new ArgumentException("Endpoint is not available!");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<T> Get<T>(string endpoint)
|
public static List<T> Get<T>(string endpoint)
|
||||||
{
|
{
|
||||||
List<T> items = new List<T>();
|
List<T> items = new List<T>();
|
||||||
HttpResponseMessage response = client.GetAsync(endpoint).GetAwaiter().GetResult();
|
HttpResponseMessage response = client.GetAsync(endpoint).GetAwaiter().GetResult();
|
||||||
if (response.IsSuccessStatusCode)
|
if (response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
items = response.Content.ReadAsAsync<List<T>>().GetAwaiter().GetResult();
|
items = response.Content.ReadAsAsync<List<T>>().GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
||||||
throw new ArgumentException(error.Msg);
|
throw new ArgumentException(error.Msg);
|
||||||
}
|
}
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T GetSingle<T>(string endpoint)
|
public static T GetSingle<T>(string endpoint)
|
||||||
{
|
{
|
||||||
T item = default(T);
|
T item = default(T);
|
||||||
HttpResponseMessage response = client.GetAsync(endpoint).GetAwaiter().GetResult();
|
HttpResponseMessage response = client.GetAsync(endpoint).GetAwaiter().GetResult();
|
||||||
if (response.IsSuccessStatusCode)
|
if (response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
item = response.Content.ReadAsAsync<T>().GetAwaiter().GetResult();
|
item = response.Content.ReadAsAsync<T>().GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
||||||
throw new ArgumentException(error.Msg);
|
throw new ArgumentException(error.Msg);
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T Get<T>(int id, string endpoint)
|
public static T Get<T>(int id, string endpoint)
|
||||||
{
|
{
|
||||||
T item = default(T);
|
T item = default(T);
|
||||||
HttpResponseMessage response = client.GetAsync(endpoint + id.ToString()).GetAwaiter().GetResult();
|
HttpResponseMessage response = client.GetAsync(endpoint + id.ToString()).GetAwaiter().GetResult();
|
||||||
if (response.IsSuccessStatusCode)
|
if (response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
item = response.Content.ReadAsAsync<T>().GetAwaiter().GetResult();
|
item = response.Content.ReadAsAsync<T>().GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
||||||
throw new ArgumentException(error.Msg);
|
throw new ArgumentException(error.Msg);
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Post<T>(T item, string endpoint)
|
public static void Post<T>(T item, string endpoint)
|
||||||
{
|
{
|
||||||
HttpResponseMessage response =
|
HttpResponseMessage response =
|
||||||
client.PostAsJsonAsync(endpoint, item).GetAwaiter().GetResult();
|
client.PostAsJsonAsync(endpoint, item).GetAwaiter().GetResult();
|
||||||
|
|
||||||
if (!response.IsSuccessStatusCode)
|
if (!response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
||||||
throw new ArgumentException(error.Msg);
|
throw new ArgumentException(error.Msg);
|
||||||
}
|
}
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Delete(int id, string endpoint)
|
public static void Delete(int id, string endpoint)
|
||||||
{
|
{
|
||||||
HttpResponseMessage response =
|
HttpResponseMessage response =
|
||||||
client.DeleteAsync(endpoint + id.ToString()).GetAwaiter().GetResult();
|
client.DeleteAsync(endpoint + id.ToString()).GetAwaiter().GetResult();
|
||||||
|
|
||||||
if (!response.IsSuccessStatusCode)
|
if (!response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
||||||
throw new ArgumentException(error.Msg);
|
throw new ArgumentException(error.Msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Put<T>(T item, string endpoint)
|
public static void Put<T>(T item, string endpoint)
|
||||||
{
|
{
|
||||||
HttpResponseMessage response =
|
HttpResponseMessage response =
|
||||||
client.PutAsJsonAsync(endpoint, item).GetAwaiter().GetResult();
|
client.PutAsJsonAsync(endpoint, item).GetAwaiter().GetResult();
|
||||||
|
|
||||||
if (!response.IsSuccessStatusCode)
|
if (!response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
||||||
throw new ArgumentException(error.Msg);
|
throw new ArgumentException(error.Msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Employee> WhoWorksInMaintainerTeam(int id)
|
public static List<Employee> WhoWorksInMaintainerTeam(int id)
|
||||||
{
|
{
|
||||||
var item = default(List<Employee>);
|
var item = default(List<Employee>);
|
||||||
HttpResponseMessage response = client.GetAsync("/api/WhoWorksInMaintainerTeam?id=" + id.ToString()).GetAwaiter().GetResult();
|
HttpResponseMessage response = client.GetAsync("/api/WhoWorksInMaintainerTeam?id=" + id.ToString()).GetAwaiter().GetResult();
|
||||||
if (response.IsSuccessStatusCode)
|
if (response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
item = response.Content.ReadAsAsync<List<Employee>>().GetAwaiter().GetResult();
|
item = response.Content.ReadAsAsync<List<Employee>>().GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
||||||
throw new ArgumentException(error.Msg);
|
throw new ArgumentException(error.Msg);
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Employee> GetSubordinates(int id)
|
public static List<Employee> GetSubordinates(int id)
|
||||||
{
|
{
|
||||||
var item = default(List<Employee>);
|
var item = default(List<Employee>);
|
||||||
HttpResponseMessage response = client.GetAsync("/api/GetSubordinates?id=" + id.ToString()).GetAwaiter().GetResult();
|
HttpResponseMessage response = client.GetAsync("/api/GetSubordinates?id=" + id.ToString()).GetAwaiter().GetResult();
|
||||||
if (response.IsSuccessStatusCode)
|
if (response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
item = response.Content.ReadAsAsync<List<Employee>>().GetAwaiter().GetResult();
|
item = response.Content.ReadAsAsync<List<Employee>>().GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
||||||
throw new ArgumentException(error.Msg);
|
throw new ArgumentException(error.Msg);
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Customer> WhoUsesService(int id)
|
public static List<Customer> WhoUsesService(int id)
|
||||||
{
|
{
|
||||||
var item = default(List<Customer>);
|
var item = default(List<Customer>);
|
||||||
HttpResponseMessage response = client.GetAsync("/api/WhoUsesService?id=" + id.ToString()).GetAwaiter().GetResult();
|
HttpResponseMessage response = client.GetAsync("/api/WhoUsesService?id=" + id.ToString()).GetAwaiter().GetResult();
|
||||||
if (response.IsSuccessStatusCode)
|
if (response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
item = response.Content.ReadAsAsync<List<Customer>>().GetAwaiter().GetResult();
|
item = response.Content.ReadAsAsync<List<Customer>>().GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
||||||
throw new ArgumentException(error.Msg);
|
throw new ArgumentException(error.Msg);
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Employee WhoIsResponsibleForService(int id)
|
public static Employee WhoIsResponsibleForService(int id)
|
||||||
{
|
{
|
||||||
Employee item = default(Employee);
|
Employee item = default(Employee);
|
||||||
HttpResponseMessage response = client.GetAsync("/api/WhoIsResponsibleForService?id=" + id.ToString()).GetAwaiter().GetResult();
|
HttpResponseMessage response = client.GetAsync("/api/WhoIsResponsibleForService?id=" + id.ToString()).GetAwaiter().GetResult();
|
||||||
if (response.IsSuccessStatusCode)
|
if (response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
item = response.Content.ReadAsAsync<Employee>().GetAwaiter().GetResult();
|
item = response.Content.ReadAsAsync<Employee>().GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
||||||
throw new ArgumentException(error.Msg);
|
throw new ArgumentException(error.Msg);
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Employee> WhoMaintainsService(int id)
|
public static List<Employee> WhoMaintainsService(int id)
|
||||||
{
|
{
|
||||||
var item = default(List<Employee>);
|
var item = default(List<Employee>);
|
||||||
HttpResponseMessage response = client.GetAsync("/api/WhoMaintainsService?id=" + id.ToString()).GetAwaiter().GetResult();
|
HttpResponseMessage response = client.GetAsync("/api/WhoMaintainsService?id=" + id.ToString()).GetAwaiter().GetResult();
|
||||||
if (response.IsSuccessStatusCode)
|
if (response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
item = response.Content.ReadAsAsync<List<Employee>>().GetAwaiter().GetResult();
|
item = response.Content.ReadAsAsync<List<Employee>>().GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
var error = response.Content.ReadAsAsync<RestExceptionInfo>().GetAwaiter().GetResult();
|
||||||
throw new ArgumentException(error.Msg);
|
throw new ArgumentException(error.Msg);
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RestExceptionInfo
|
public class RestExceptionInfo
|
||||||
{
|
{
|
||||||
public RestExceptionInfo()
|
public RestExceptionInfo()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
public string Msg { get; set; }
|
public string Msg { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class EndpointNotAvailableException : Exception
|
public class EndpointNotAvailableException : Exception
|
||||||
{
|
{
|
||||||
public EndpointNotAvailableException() : base("The client could not reach the API endpoint.")
|
public EndpointNotAvailableException() : base("The client could not reach the API endpoint.")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public EndpointNotAvailableException(string message) : base(message)
|
public EndpointNotAvailableException(string message) : base(message)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public EndpointNotAvailableException(string message, Exception innerException) : base(message, innerException)
|
public EndpointNotAvailableException(string message, Exception innerException) : base(message, innerException)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="6.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\WD7UVN_HFT_2023241.Models\WD7UVN_HFT_2023241.Models.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -4,8 +4,9 @@ using System.Net.NetworkInformation;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using ConsoleTools;
|
using ConsoleTools;
|
||||||
using WD7UVN_HFT_2023241.Models;
|
using WD7UVN_HFT_2023241.Models;
|
||||||
|
using WD7UVN_HFT_2023241.Client.Shared;
|
||||||
|
|
||||||
namespace WD7UVN_HFT_2023241.Client
|
namespace WD7UVN_HFT_2023241.Client.TUI
|
||||||
{
|
{
|
||||||
public class CRUD
|
public class CRUD
|
||||||
{
|
{
|
||||||
@@ -2,9 +2,10 @@ using System;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using ConsoleTools;
|
using ConsoleTools;
|
||||||
|
using WD7UVN_HFT_2023241.Client.Shared;
|
||||||
using WD7UVN_HFT_2023241.Models;
|
using WD7UVN_HFT_2023241.Models;
|
||||||
|
|
||||||
namespace WD7UVN_HFT_2023241.Client
|
namespace WD7UVN_HFT_2023241.Client.TUI
|
||||||
{
|
{
|
||||||
public class NonCRUD
|
public class NonCRUD
|
||||||
{
|
{
|
||||||
@@ -1,83 +1,84 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using ConsoleTools;
|
using ConsoleTools;
|
||||||
|
using WD7UVN_HFT_2023241.Client.Shared;
|
||||||
namespace WD7UVN_HFT_2023241.Client
|
|
||||||
{
|
namespace WD7UVN_HFT_2023241.Client.TUI
|
||||||
public enum CRUDActions
|
{
|
||||||
{
|
public enum CRUDActions
|
||||||
GetAll,
|
{
|
||||||
GetById,
|
GetAll,
|
||||||
Create,
|
GetById,
|
||||||
Update,
|
Create,
|
||||||
Delete
|
Update,
|
||||||
}
|
Delete
|
||||||
|
}
|
||||||
public class Program
|
|
||||||
{
|
public class Program
|
||||||
private static async Task Main(string[] args)
|
{
|
||||||
{
|
private static async Task Main(string[] args)
|
||||||
try
|
{
|
||||||
{
|
try
|
||||||
RestService.Init();
|
{
|
||||||
}
|
RestService.Init();
|
||||||
catch (EndpointNotAvailableException e)
|
}
|
||||||
{
|
catch (EndpointNotAvailableException e)
|
||||||
Console.WriteLine(e.Message);
|
{
|
||||||
Environment.Exit(1);
|
Console.WriteLine(e.Message);
|
||||||
}
|
Environment.Exit(1);
|
||||||
|
}
|
||||||
// var commonConfig = new MenuConfig
|
|
||||||
// {
|
// var commonConfig = new MenuConfig
|
||||||
// Selector = "--> ",
|
// {
|
||||||
// EnableFilter = true,
|
// Selector = "--> ",
|
||||||
// EnableBreadcrumb = true,
|
// EnableFilter = true,
|
||||||
// WriteBreadcrumbAction = titles => Console.WriteLine(string.Join(" / ", titles)),
|
// EnableBreadcrumb = true,
|
||||||
// };
|
// WriteBreadcrumbAction = titles => Console.WriteLine(string.Join(" / ", titles)),
|
||||||
|
// };
|
||||||
var nonCrudMenu = new ConsoleMenu(args, level: 2)
|
|
||||||
.Add("Who maintains specified service?", () => NonCRUD.WhoMaintainsService())
|
var nonCrudMenu = new ConsoleMenu(args, level: 2)
|
||||||
.Add("Get employee's subordinates", () => NonCRUD.GetSubordinates())
|
.Add("Who maintains specified service?", () => NonCRUD.WhoMaintainsService())
|
||||||
.Add("Get clients using a specified service", () => NonCRUD.WhoUsesService())
|
.Add("Get employee's subordinates", () => NonCRUD.GetSubordinates())
|
||||||
.Add("Get employees in specified maintainer team", () => NonCRUD.WhoWorksInMaintainerTeam())
|
.Add("Get clients using a specified service", () => NonCRUD.WhoUsesService())
|
||||||
.Add("Get employee responsible for specified service", () => NonCRUD.WhoIsResponsibleForService())
|
.Add("Get employees in specified maintainer team", () => NonCRUD.WhoWorksInMaintainerTeam())
|
||||||
.Add("Back", ConsoleMenu.Close)
|
.Add("Get employee responsible for specified service", () => NonCRUD.WhoIsResponsibleForService())
|
||||||
.Add("Exit", () => Environment.Exit(0))
|
.Add("Back", ConsoleMenu.Close)
|
||||||
//.Configure(commonConfig)
|
.Add("Exit", () => Environment.Exit(0))
|
||||||
.Configure(config =>
|
//.Configure(commonConfig)
|
||||||
{
|
.Configure(config =>
|
||||||
config.Title = "Non-CRUD Operations";
|
{
|
||||||
});
|
config.Title = "Non-CRUD Operations";
|
||||||
|
});
|
||||||
var crudMenu = new ConsoleMenu(args, level: 1)
|
|
||||||
.Add("Get all", () => CRUD.TypeSelectorMenu(CRUDActions.GetAll))
|
var crudMenu = new ConsoleMenu(args, level: 1)
|
||||||
.Add("Get by id", () => CRUD.TypeSelectorMenu(CRUDActions.GetById))
|
.Add("Get all", () => CRUD.TypeSelectorMenu(CRUDActions.GetAll))
|
||||||
.Add("Create", () => CRUD.TypeSelectorMenu(CRUDActions.Create))
|
.Add("Get by id", () => CRUD.TypeSelectorMenu(CRUDActions.GetById))
|
||||||
.Add("Update", () => CRUD.TypeSelectorMenu(CRUDActions.Update))
|
.Add("Create", () => CRUD.TypeSelectorMenu(CRUDActions.Create))
|
||||||
.Add("Delete", () => CRUD.TypeSelectorMenu(CRUDActions.Delete))
|
.Add("Update", () => CRUD.TypeSelectorMenu(CRUDActions.Update))
|
||||||
.Add("Back", ConsoleMenu.Close)
|
.Add("Delete", () => CRUD.TypeSelectorMenu(CRUDActions.Delete))
|
||||||
.Add("Exit", () => Environment.Exit(0))
|
.Add("Back", ConsoleMenu.Close)
|
||||||
//.Configure(commonConfig)
|
.Add("Exit", () => Environment.Exit(0))
|
||||||
.Configure(config =>
|
//.Configure(commonConfig)
|
||||||
{
|
.Configure(config =>
|
||||||
config.Title = "Tables";
|
{
|
||||||
});
|
config.Title = "Tables";
|
||||||
|
});
|
||||||
var menu = new ConsoleMenu(args, level: 0)
|
|
||||||
.Add("CRUD", crudMenu.Show)
|
var menu = new ConsoleMenu(args, level: 0)
|
||||||
.Add("Non-CRUD", nonCrudMenu.Show)
|
.Add("CRUD", crudMenu.Show)
|
||||||
.Add("Exit", () => Environment.Exit(0))
|
.Add("Non-CRUD", nonCrudMenu.Show)
|
||||||
//.Configure(commonConfig)
|
.Add("Exit", () => Environment.Exit(0))
|
||||||
.Configure(config =>
|
//.Configure(commonConfig)
|
||||||
{
|
.Configure(config =>
|
||||||
config.Title = "Main menu";
|
{
|
||||||
config.EnableWriteTitle = true;
|
config.Title = "Main menu";
|
||||||
config.EnableBreadcrumb = true;
|
config.EnableWriteTitle = true;
|
||||||
});
|
config.EnableBreadcrumb = true;
|
||||||
|
});
|
||||||
var token = new CancellationTokenSource().Token;
|
|
||||||
await menu.ShowAsync(token);
|
var token = new CancellationTokenSource().Token;
|
||||||
}
|
await menu.ShowAsync(token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net5.0</TargetFramework>
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\WD7UVN_HFT_2023241.Models\WD7UVN_HFT_2023241.Models.csproj" />
|
<ProjectReference Include="..\..\WD7UVN_HFT_2023241.Models\WD7UVN_HFT_2023241.Models.csproj" />
|
||||||
</ItemGroup>
|
<ProjectReference Include="..\Shared\WD7UVN_HFT_2023241.Client.Shared.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ConsoleMenu-simple" Version="2.6.1" />
|
<PackageReference Include="ConsoleMenu-simple" Version="2.6.1" />
|
||||||
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="6.0.0" />
|
</ItemGroup>
|
||||||
</ItemGroup>
|
|
||||||
|
</Project>
|
||||||
</Project>
|
|
||||||
@@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.0.31903.59
|
VisualStudioVersion = 17.0.31903.59
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WD7UVN_HFT_2023241.Client", "WD7UVN_HFT_2023241.Client\WD7UVN_HFT_2023241.Client.csproj", "{1B081783-46AB-44BF-A934-DF672F8A6228}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WD7UVN_HFT_2023241.Models", "WD7UVN_HFT_2023241.Models\WD7UVN_HFT_2023241.Models.csproj", "{BF8B019B-979F-4612-A126-5886A4C7D4F0}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WD7UVN_HFT_2023241.Models", "WD7UVN_HFT_2023241.Models\WD7UVN_HFT_2023241.Models.csproj", "{BF8B019B-979F-4612-A126-5886A4C7D4F0}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WD7UVN_HFT_2023241.Logic", "WD7UVN_HFT_2023241.Logic\WD7UVN_HFT_2023241.Logic.csproj", "{EEBE5ED0-A0D2-45C2-82F8-E7ECD62BEE8A}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WD7UVN_HFT_2023241.Logic", "WD7UVN_HFT_2023241.Logic\WD7UVN_HFT_2023241.Logic.csproj", "{EEBE5ED0-A0D2-45C2-82F8-E7ECD62BEE8A}"
|
||||||
@@ -21,16 +19,18 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Frontend", "Frontend", "{8F
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{18D51E10-9339-4A0D-AC44-625FF7A19050}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{18D51E10-9339-4A0D-AC44-625FF7A19050}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WD7UVN_HFT_2023241.Client.TUI", "WD7UVN_HFT_2023241.Client\TUI\WD7UVN_HFT_2023241.Client.TUI.csproj", "{F68C5B1A-C3B9-4AFC-BBD3-9DCC02A22EA0}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WD7UVN_HFT_2023241.Client.Shared", "WD7UVN_HFT_2023241.Client\Shared\WD7UVN_HFT_2023241.Client.Shared.csproj", "{77C8BEDB-0D81-4703-8FBC-B4DCD32584BD}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WD7UVN_SzTGUI_2023242.Client.WPF", "WD7UVN_SzTGUI_2023242.Client.WPF\WD7UVN_SzTGUI_2023242.Client.WPF.csproj", "{0A994D03-066F-43E7-872E-4D239FC6F764}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
Release|Any CPU = Release|Any CPU
|
Release|Any CPU = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{1B081783-46AB-44BF-A934-DF672F8A6228}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{1B081783-46AB-44BF-A934-DF672F8A6228}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{1B081783-46AB-44BF-A934-DF672F8A6228}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{1B081783-46AB-44BF-A934-DF672F8A6228}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{BF8B019B-979F-4612-A126-5886A4C7D4F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{BF8B019B-979F-4612-A126-5886A4C7D4F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{BF8B019B-979F-4612-A126-5886A4C7D4F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{BF8B019B-979F-4612-A126-5886A4C7D4F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{BF8B019B-979F-4612-A126-5886A4C7D4F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{BF8B019B-979F-4612-A126-5886A4C7D4F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
@@ -51,17 +51,31 @@ Global
|
|||||||
{63F3B585-3E8C-41F5-8D6C-FB59932D0819}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{63F3B585-3E8C-41F5-8D6C-FB59932D0819}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{63F3B585-3E8C-41F5-8D6C-FB59932D0819}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{63F3B585-3E8C-41F5-8D6C-FB59932D0819}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{63F3B585-3E8C-41F5-8D6C-FB59932D0819}.Release|Any CPU.Build.0 = Release|Any CPU
|
{63F3B585-3E8C-41F5-8D6C-FB59932D0819}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{F68C5B1A-C3B9-4AFC-BBD3-9DCC02A22EA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{F68C5B1A-C3B9-4AFC-BBD3-9DCC02A22EA0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{F68C5B1A-C3B9-4AFC-BBD3-9DCC02A22EA0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{F68C5B1A-C3B9-4AFC-BBD3-9DCC02A22EA0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{77C8BEDB-0D81-4703-8FBC-B4DCD32584BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{77C8BEDB-0D81-4703-8FBC-B4DCD32584BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{77C8BEDB-0D81-4703-8FBC-B4DCD32584BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{77C8BEDB-0D81-4703-8FBC-B4DCD32584BD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{0A994D03-066F-43E7-872E-4D239FC6F764}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{0A994D03-066F-43E7-872E-4D239FC6F764}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{0A994D03-066F-43E7-872E-4D239FC6F764}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{0A994D03-066F-43E7-872E-4D239FC6F764}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(NestedProjects) = preSolution
|
GlobalSection(NestedProjects) = preSolution
|
||||||
{1B081783-46AB-44BF-A934-DF672F8A6228} = {8FABCF39-D228-4E36-927D-09B4CCF88935}
|
|
||||||
{BF8B019B-979F-4612-A126-5886A4C7D4F0} = {18D51E10-9339-4A0D-AC44-625FF7A19050}
|
{BF8B019B-979F-4612-A126-5886A4C7D4F0} = {18D51E10-9339-4A0D-AC44-625FF7A19050}
|
||||||
{EEBE5ED0-A0D2-45C2-82F8-E7ECD62BEE8A} = {E7A96BA5-BFD6-4265-A90F-880015BEFE07}
|
{EEBE5ED0-A0D2-45C2-82F8-E7ECD62BEE8A} = {E7A96BA5-BFD6-4265-A90F-880015BEFE07}
|
||||||
{9430B2D2-3137-4DCA-BEFB-7E926D4E3583} = {E7A96BA5-BFD6-4265-A90F-880015BEFE07}
|
{9430B2D2-3137-4DCA-BEFB-7E926D4E3583} = {E7A96BA5-BFD6-4265-A90F-880015BEFE07}
|
||||||
{316342CA-7521-4A01-8BDB-5AA76D4DE855} = {E7A96BA5-BFD6-4265-A90F-880015BEFE07}
|
{316342CA-7521-4A01-8BDB-5AA76D4DE855} = {E7A96BA5-BFD6-4265-A90F-880015BEFE07}
|
||||||
{63F3B585-3E8C-41F5-8D6C-FB59932D0819} = {E7A96BA5-BFD6-4265-A90F-880015BEFE07}
|
{63F3B585-3E8C-41F5-8D6C-FB59932D0819} = {E7A96BA5-BFD6-4265-A90F-880015BEFE07}
|
||||||
|
{F68C5B1A-C3B9-4AFC-BBD3-9DCC02A22EA0} = {8FABCF39-D228-4E36-927D-09B4CCF88935}
|
||||||
|
{77C8BEDB-0D81-4703-8FBC-B4DCD32584BD} = {8FABCF39-D228-4E36-927D-09B4CCF88935}
|
||||||
|
{0A994D03-066F-43E7-872E-4D239FC6F764} = {8FABCF39-D228-4E36-927D-09B4CCF88935}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {B8B81AFF-A1C2-46B5-8CF1-BBA9BAEB756F}
|
SolutionGuid = {B8B81AFF-A1C2-46B5-8CF1-BBA9BAEB756F}
|
||||||
|
|||||||
9
WD7UVN_SzTGUI_2023242.Client.WPF/App.xaml
Normal file
9
WD7UVN_SzTGUI_2023242.Client.WPF/App.xaml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<Application x:Class="WD7UVN_SzTGUI_2023242.Client.WPF.App"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="clr-namespace:WD7UVN_SzTGUI_2023242.Client.WPF"
|
||||||
|
StartupUri="MainWindow.xaml">
|
||||||
|
<Application.Resources>
|
||||||
|
|
||||||
|
</Application.Resources>
|
||||||
|
</Application>
|
||||||
17
WD7UVN_SzTGUI_2023242.Client.WPF/App.xaml.cs
Normal file
17
WD7UVN_SzTGUI_2023242.Client.WPF/App.xaml.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Configuration;
|
||||||
|
using System.Data;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace WD7UVN_SzTGUI_2023242.Client.WPF
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for App.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class App : Application
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
10
WD7UVN_SzTGUI_2023242.Client.WPF/AssemblyInfo.cs
Normal file
10
WD7UVN_SzTGUI_2023242.Client.WPF/AssemblyInfo.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
[assembly: ThemeInfo(
|
||||||
|
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// or application resource dictionaries)
|
||||||
|
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// app, or any theme specific resource dictionaries)
|
||||||
|
)]
|
||||||
12
WD7UVN_SzTGUI_2023242.Client.WPF/MainWindow.xaml
Normal file
12
WD7UVN_SzTGUI_2023242.Client.WPF/MainWindow.xaml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<Window x:Class="WD7UVN_SzTGUI_2023242.Client.WPF.MainWindow"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:WD7UVN_SzTGUI_2023242.Client.WPF"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="MainWindow" Height="450" Width="800">
|
||||||
|
<Grid>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
28
WD7UVN_SzTGUI_2023242.Client.WPF/MainWindow.xaml.cs
Normal file
28
WD7UVN_SzTGUI_2023242.Client.WPF/MainWindow.xaml.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Navigation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
|
namespace WD7UVN_SzTGUI_2023242.Client.WPF
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for MainWindow.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class MainWindow : Window
|
||||||
|
{
|
||||||
|
public MainWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net5.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWPF>true</UseWPF>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup />
|
||||||
|
<ItemGroup>
|
||||||
|
<ApplicationDefinition Update="App.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</ApplicationDefinition>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Page Update="MainWindow.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Page>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
Reference in New Issue
Block a user