странички!

This commit is contained in:
a.puchkina 2024-05-01 20:47:42 +04:00
parent 47a1f54b4a
commit 723f7940c4
16 changed files with 466 additions and 0 deletions

View File

@ -0,0 +1,45 @@
using LawFirmContracts.ViewModels;
using Newtonsoft.Json;
using System.Net.Http.Headers;
using System.Text;
namespace LawFirmGuarantorApp
{
public class APIClient
{
private static readonly HttpClient _lawyer = new();
public static GuarantorViewModel? Guarantor { get; set; } = null;
public static void Connect(IConfiguration configuration)
{
_lawyer.BaseAddress = new Uri(configuration["IPAddress"]);
_lawyer.DefaultRequestHeaders.Accept.Clear();
_lawyer.DefaultRequestHeaders.Accept.Add(new
MediaTypeWithQualityHeaderValue("application/json"));
}
public static T? GetRequest<T>(string requestUrl)
{
var response = _lawyer.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 = _lawyer.PostAsync(requestUrl, data);
var result = response.Result.Content.ReadAsStringAsync().Result;
if (!response.Result.IsSuccessStatusCode)
{
throw new Exception(result);
}
}
}
}

View File

@ -0,0 +1,12 @@
using Microsoft.AspNetCore.Mvc;
namespace LawFirmGuarantorApp.Controllers
{
public class ConsultationController : Controller
{
public IActionResult Index()
{
return View();
}
}
}

View File

@ -0,0 +1,12 @@
using Microsoft.AspNetCore.Mvc;
namespace LawFirmGuarantorApp.Controllers
{
public class HearingController : Controller
{
public IActionResult Index()
{
return View();
}
}
}

View File

@ -0,0 +1,12 @@
using Microsoft.AspNetCore.Mvc;
namespace LawFirmGuarantorApp.Controllers
{
public class LawyerController : Controller
{
public IActionResult Index()
{
return View();
}
}
}

View File

@ -6,6 +6,10 @@
<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" />

View File

@ -1,4 +1,11 @@
using LawFirmContracts.StoragesContracts;
using LawFirmDatabaseImplement.Implements;
using LawFirmGuarantorApp;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddTransient<IConsultationStorage, ConsultationStorage>();
builder.Services.AddTransient<IHearingStorage, HearingStorage>();
builder.Services.AddTransient<ILawyerStorage, LawyerStorage>();
// Add services to the container.
builder.Services.AddControllersWithViews();

View File

@ -0,0 +1,31 @@
@{
ViewData["Title"] = "Добавить юристов";
Layout = "~/Views/Shared/_LayoutGuarantor.cshtml";
}
<style>
</style>
<div class="text-center">
<h2 class="display-4">Добавить юристов</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Юрист</div>
<div class="col-8">
<select id="lawyerId" name="lawyerId" class="form-control" asp-items="@(new SelectList(@ViewBag.Lawyers,"Id", "FIO"))"></select>
</div>
</div>
<div class="row">
<div class="col-4">Консультация</div>
<div class="col-8">
<select id="conId" name="conId" class="form-control" asp-items="@(new SelectList(@ViewBag.Consultations,"Id", "Cost"))"></select>
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4">
<input type="submit" value="Создать" class="btn
btn-primary" />
</div>
</div>
</form>

View File

@ -0,0 +1,61 @@
@using LawFirmContracts.ViewModels;
@model List<LawyerViewModel>
@{
ViewData["Title"] = "Юристы";
Layout = "~/Views/Shared/_LayoutGuarantor.cshtml";
}
<div class="text-center">
<h1 class="display-4">Юристы</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
<table class="table">
<thead>
<tr>
<th>
Номер юриста
</th>
<th>
ФИО
</th>
<th>
Телефон
</th>
<th>
Email
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td id="id">
@Html.DisplayFor(modelItem =>
item.Id)
</td>
<td>
@Html.DisplayFor(modelItem =>
item.FIO)
</td>
<td>
@Html.DisplayFor(modelItem =>
item.Phone)
</td>
<td>
@Html.DisplayFor(modelItem =>
item.Email)
</td>
</tr>
}
</tbody>
</table>
}
</div>

View File

@ -0,0 +1,34 @@
@{
ViewData["Title"] = "Создание консультацию";
Layout = "~/Views/Shared/_LayoutGuarantor.cshtml";
}
<div class="text-center">
<h2 class="display-4">Создание консультации</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Стоимость консультации</div>
<div class="col-8">
<input type="number" id="cost" name="cost">
</div>
</div>
<div class="row">
<div class="col-4">Дата и время</div>
<div class="col-8">
<input type="datetime-local" placeholder="Введите дату" name="consultationDate" id="consultationDate">
</div>
</div>
<div class="row">
<div class="col-4">Дело</div>
<div class="col-8">
<select id="caseId" name="caseId" class="form-control" asp-items="@(new SelectList(@ViewBag.Cases,"Id", "Id"))"></select>
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4">
<input type="submit" value="Создать" class="btn btn-primary" />
</div>
</div>
</form>

View File

@ -0,0 +1,34 @@
@{
ViewData["Title"] = "Обновление консультации";
Layout = "~/Views/Shared/_LayoutGuarantor.cshtml";
}
<div class="text-center">
<h2 class="display-4">Обновление консультации</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Стоимость</div>
<div class="col-8">
<input type="text" name="cost" id="cost" />
</div>
</div>
<div class="row">
<div class="col-4">Дата</div>
<div class="col-8">
<input type="text" name="date" id="date" />
</div>
</div>
<div class="row">
<div class="col-4">Дело</div>
<div class="col-8">
<select id="caseId" name="caseId" class="form-control" asp-items="@(new SelectList(@ViewBag.Cases,"Id", "Id"))"></select>
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4">
<input type="submit" value="Обновить" class="btn btn-primary" />
</div>
</div>
</form>

View File

@ -0,0 +1,30 @@
@{
ViewData["Title"] = "Добавить юристов";
Layout = "~/Views/Shared/_LayoutGuarantor.cshtml";
}
<style>
</style>
<div class="text-center">
<h2 class="display-4">Добавить юристов</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Слушание</div>
<div class="col-8">
<select id="id" name="id" class="form-control" asp-items="@(new SelectList(@ViewBag.Hearings,"Id", "Name"))"></select>
</div>
</div>
<div class="row">
<div class="col-4">Юрист</div>
<div class="col-8">
<select id="lawyerId" name="lawyerId" class="form-control" asp-items="@(new SelectList(@ViewBag.Hearings,"Id", "FIO"))"></select>
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4">
<input type="submit" value="Создать" class="btn btn-primary" />
</div>
</div>
</form>

View File

@ -0,0 +1,28 @@
@{
ViewData["Title"] = "Назначение слушания";
Layout = "~/Views/Shared/_LayoutGuarantor.cshtml";
}
<div class="text-center">
<h2 class="display-4">Назначение слушания</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Дата слушания</div>
<div class="col-8">
<input type="datetime-local" id="date" name="date" />
</div>
</div>
<div class="row">
<div class="col-4">Суд</div>
<div class="col-8">
<input type="text" name="judge" id="judge" />
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4">
<input type="submit" value="Создать" class="btn btn-primary" />
</div>
</div>
</form>

View File

@ -0,0 +1,60 @@
@using LawFirmContracts.ViewModels;
@model List<LawyerViewModel>
@{
ViewData["Title"] = "Юристы";
Layout = "~/Views/Shared/_LayoutGuarantor.cshtml";
}
<div class="text-center">
<h1 class="display-4">Юристы</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
<table class="table">
<thead>
<tr>
<th>
Номер юриста
</th>
<th>
ФИО
</th>
<th>
Телефон
</th>
<th>
Email
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td id="id">
@Html.DisplayFor(modelItem =>
item.Id)
</td>
<td>
@Html.DisplayFor(modelItem =>
item.FIO)
</td>
<td>
@Html.DisplayFor(modelItem =>
item.Phone)
</td>
<td>
@Html.DisplayFor(modelItem =>
item.Email)
</td>
</tr>
}
</tbody>
</table>
}
</div>

View File

@ -0,0 +1,28 @@
@{
ViewData["Title"] = "UpdateHearing";
Layout = "~/Views/Shared/_LayoutGuarantor.cshtml";
}
<div class="text-center">
<h2 class="display-4">Обновление слушания </h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Дата слушания</div>
<div class="col-8">
<input type="datetime-local" id="date" name="date" />
</div>
</div>
<div class="row">
<div class="col-4">Суд</div>
<div class="col-8">
<input type="text" name="judge" id="judge" />
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4">
<input type="submit" value="Обновить" class="btn btn-primary" />
</div>
</div>
</form>

View File

@ -0,0 +1,34 @@
@{
ViewData["Title"] = "Создание юриста";
Layout = "~/Views/Shared/_LayoutGuarantor.cshtml";
}
<div class="text-center">
<h2 class="display-4">Создание юриста </h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">ФИО</div>
<div class="col-8">
<input type="text" name="fio" id="fio" />
</div>
</div>
<div class="row">
<div class="col-4">Номер телефона</div>
<div class="col-8">
<input type="number" id="phone" name="phone" />
</div>
</div>
<div class="row">
<div class="col-4">E-mail</div>
<div class="col-8">
<input type="text" name="email" id="email" />
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4">
<input type="submit" value="Создать" class="btn btn-primary" />
</div>
</div>
</form>

View File

@ -0,0 +1,34 @@
@{
ViewData["Title"] = "Обновить юриста";
Layout = "~/Views/Shared/_LayoutGuarantor.cshtml";
}
<div class="text-center">
<h2 class="display-4">Изменение юриста</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">ФИО</div>
<div class="col-8">
<input type="text" name="fio" id="fio" />
</div>
</div>
<div class="row">
<div class="col-4">Номер телефона</div>
<div class="col-8">
<input type="number" id="phone" name="phone" />
</div>
</div>
<div class="row">
<div class="col-4">E-mail</div>
<div class="col-8">
<input type="text" name="email" id="email" />
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4">
<input type="submit" value="Обновить" class="btn btn-primary" />
</div>
</div>
</form>