хорошо, что на похоронах не ловят букеты
This commit is contained in:
parent
79388d64d3
commit
5997176256
43
LawFim/LawFirmExecutorApp/APIClient.cs
Normal file
43
LawFim/LawFirmExecutorApp/APIClient.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using LawFirmContracts.ViewModels;
|
||||
using Newtonsoft.Json;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
|
||||
namespace LawFirmExecutorApp
|
||||
{
|
||||
public class APIClient
|
||||
{
|
||||
private static readonly HttpClient _client = new();
|
||||
public static ExecutorViewModel? Executor { get; set; } = null;
|
||||
public static void Connect(IConfiguration configuration)
|
||||
{
|
||||
_client.BaseAddress = new Uri(configuration["IPAddress"]);
|
||||
_client.DefaultRequestHeaders.Accept.Clear();
|
||||
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
}
|
||||
public static T? GetRequest<T>(string requestUrl)
|
||||
{
|
||||
var response = _client.GetAsync(requestUrl);
|
||||
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||
if (response.Result.IsSuccessStatusCode)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<T>(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(result);
|
||||
}
|
||||
}
|
||||
public static void PostRequest<T>(string requestUrl, T model)
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(model);
|
||||
var data = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
var response = _client.PostAsync(requestUrl, data);
|
||||
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||
if (!response.Result.IsSuccessStatusCode)
|
||||
{
|
||||
throw new Exception(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
12
LawFim/LawFirmExecutorApp/Controllers/CaseController.cs
Normal file
12
LawFim/LawFirmExecutorApp/Controllers/CaseController.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace LawFirmExecutorApp.Controllers
|
||||
{
|
||||
public class CaseController : Controller
|
||||
{
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
12
LawFim/LawFirmExecutorApp/Controllers/ClientController.cs
Normal file
12
LawFim/LawFirmExecutorApp/Controllers/ClientController.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace LawFirmExecutorApp.Controllers
|
||||
{
|
||||
public class ClientController : Controller
|
||||
{
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
12
LawFim/LawFirmExecutorApp/Controllers/VizitController.cs
Normal file
12
LawFim/LawFirmExecutorApp/Controllers/VizitController.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace LawFirmExecutorApp.Controllers
|
||||
{
|
||||
public class VizitController : Controller
|
||||
{
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
@ -6,4 +6,13 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\LawFirmContracts\LawFirmContracts.csproj" />
|
||||
<ProjectReference Include="..\LawFirmDatabaseImplement\LawFirmDatabaseImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -1,9 +1,20 @@
|
||||
using LawFirmExecutorApp;
|
||||
using LawFirmContracts.BindingModels;
|
||||
using LawFirmContracts.StoragesContracts;
|
||||
using LawFirmContracts.ViewModels;
|
||||
using LawFirmDatabaseImplement.Implements;
|
||||
using LawFimDataModels.Models;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Services.AddTransient<ICaseStorage, CaseStorage>();
|
||||
builder.Services.AddTransient<IVisitStorage, VisitStorage>();
|
||||
builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddControllersWithViews();
|
||||
|
||||
var app = builder.Build();
|
||||
APIClient.Connect(builder.Configuration);
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
|
5
LawFim/LawFirmExecutorApp/Views/Case/AddClient.cshtml
Normal file
5
LawFim/LawFirmExecutorApp/Views/Case/AddClient.cshtml
Normal file
@ -0,0 +1,5 @@
|
||||
@*
|
||||
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
*@
|
||||
@{
|
||||
}
|
5
LawFim/LawFirmExecutorApp/Views/Case/CaseClients.cshtml
Normal file
5
LawFim/LawFirmExecutorApp/Views/Case/CaseClients.cshtml
Normal file
@ -0,0 +1,5 @@
|
||||
@*
|
||||
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
*@
|
||||
@{
|
||||
}
|
5
LawFim/LawFirmExecutorApp/Views/Case/CreateCase.cshtml
Normal file
5
LawFim/LawFirmExecutorApp/Views/Case/CreateCase.cshtml
Normal file
@ -0,0 +1,5 @@
|
||||
@*
|
||||
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
*@
|
||||
@{
|
||||
}
|
5
LawFim/LawFirmExecutorApp/Views/Case/UpdateCase.cshtml
Normal file
5
LawFim/LawFirmExecutorApp/Views/Case/UpdateCase.cshtml
Normal file
@ -0,0 +1,5 @@
|
||||
@*
|
||||
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
*@
|
||||
@{
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
@*
|
||||
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
*@
|
||||
@{
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
@*
|
||||
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
*@
|
||||
@{
|
||||
}
|
5
LawFim/LawFirmExecutorApp/Views/Home/Cases.cshtml
Normal file
5
LawFim/LawFirmExecutorApp/Views/Home/Cases.cshtml
Normal file
@ -0,0 +1,5 @@
|
||||
@*
|
||||
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
*@
|
||||
@{
|
||||
}
|
5
LawFim/LawFirmExecutorApp/Views/Home/Clients.cshtml
Normal file
5
LawFim/LawFirmExecutorApp/Views/Home/Clients.cshtml
Normal file
@ -0,0 +1,5 @@
|
||||
@*
|
||||
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
*@
|
||||
@{
|
||||
}
|
5
LawFim/LawFirmExecutorApp/Views/Home/Enter.cshtml
Normal file
5
LawFim/LawFirmExecutorApp/Views/Home/Enter.cshtml
Normal file
@ -0,0 +1,5 @@
|
||||
@*
|
||||
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
*@
|
||||
@{
|
||||
}
|
5
LawFim/LawFirmExecutorApp/Views/Home/Register.cshtml
Normal file
5
LawFim/LawFirmExecutorApp/Views/Home/Register.cshtml
Normal file
@ -0,0 +1,5 @@
|
||||
@*
|
||||
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
*@
|
||||
@{
|
||||
}
|
5
LawFim/LawFirmExecutorApp/Views/Home/Visits.cshtml
Normal file
5
LawFim/LawFirmExecutorApp/Views/Home/Visits.cshtml
Normal file
@ -0,0 +1,5 @@
|
||||
@*
|
||||
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
*@
|
||||
@{
|
||||
}
|
5
LawFim/LawFirmExecutorApp/Views/Visit/AddClient.cshtml
Normal file
5
LawFim/LawFirmExecutorApp/Views/Visit/AddClient.cshtml
Normal file
@ -0,0 +1,5 @@
|
||||
@*
|
||||
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
*@
|
||||
@{
|
||||
}
|
5
LawFim/LawFirmExecutorApp/Views/Visit/CreateVisit.cshtml
Normal file
5
LawFim/LawFirmExecutorApp/Views/Visit/CreateVisit.cshtml
Normal file
@ -0,0 +1,5 @@
|
||||
@*
|
||||
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
*@
|
||||
@{
|
||||
}
|
5
LawFim/LawFirmExecutorApp/Views/Visit/UpdateVisit.cshtml
Normal file
5
LawFim/LawFirmExecutorApp/Views/Visit/UpdateVisit.cshtml
Normal file
@ -0,0 +1,5 @@
|
||||
@*
|
||||
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
*@
|
||||
@{
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
@*
|
||||
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
*@
|
||||
@{
|
||||
}
|
@ -5,5 +5,6 @@
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
"AllowedHosts": "*",
|
||||
"IPAddress": "http://localhost:5223/"
|
||||
}
|
||||
|
@ -6,4 +6,9 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\LawFirmContracts\LawFirmContracts.csproj" />
|
||||
<ProjectReference Include="..\LawFirmDatabaseImplement\LawFirmDatabaseImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
Loading…
x
Reference in New Issue
Block a user