Далеко не факт, что работает

This commit is contained in:
maxnes3 2023-05-18 23:32:19 +04:00
parent b00c7e0c03
commit 82028c2fdd
32 changed files with 1371 additions and 36 deletions

View File

@ -17,6 +17,7 @@ namespace CaseAccountingContracts.ViewModels
[DisplayName("Номер дела")] [DisplayName("Номер дела")]
public int CaseId { get; set; } public int CaseId { get; set; }
public int UserId { get; set; } public int UserId { get; set; }
[DisplayName("Номер слушания")]
public int Id { get; set; } public int Id { get; set; }
} }
} }

View File

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

View File

@ -6,4 +6,12 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CaseAccountingContracts\CaseAccountingContracts.csproj" />
</ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,123 @@
using CaseAccountingContracts.BindingModels;
using CaseAccountingContracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
namespace CaseAccountingProviderView.Controllers
{
public class CaseController : Controller
{
public IActionResult Create()
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
return View();
}
[HttpPost]
public void Create([FromBody] CaseBindingModel caseModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
caseModel.UserId = APIUser.User.Id;
APIUser.PostRequest("api/case/create", caseModel);
Response.Redirect("/Home/Cases");
}
public IActionResult Update(int id)
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Case = APIUser.GetRequest<CaseViewModel>($"api/case/get?id={id}");
return View();
}
[HttpPost]
public void Update([FromBody] CaseBindingModel caseModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
caseModel.UserId = APIUser.User.Id;
APIUser.PostRequest("api/case/update", caseModel);
Response.Redirect("/Home/Cases");
}
public IActionResult AddCase(int id)
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.CaseId = id;
return View();
}
[HttpPost]
public void AddCase([FromBody] CaseBindingModel caseModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
APIUser.PostRequest("api/case/update", caseModel);
}
public IActionResult Bind(int id)
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Case = APIUser.GetRequest<CaseViewModel>($"api/case/get?id={id}");
return View();
}
[HttpPost]
public void Bind([FromBody] CaseBindingModel caseModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
APIUser.PostRequest("api/case/update", caseModel);
}
[HttpPost]
public void Delete(int id)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
APIUser.PostRequest($"api/case/delete", new CaseBindingModel() { Id = id });
Response.Redirect("/Home/Cases");
}
public List<CaseViewModel> GetAllByUser()
{
if (APIUser.User == null)
{
return new();
}
List<CaseViewModel>? caseModel = APIUser.GetRequest<List<CaseViewModel>>($"api/case/getallbyuser?userId={APIUser.User.Id}");
return caseModel ?? new();
}
public CaseViewModel? Get(int id)
{
if (APIUser.User == null)
{
return new();
}
CaseViewModel? caseModel = APIUser.GetRequest<CaseViewModel>($"api/case/get?id={id}");
return caseModel;
}
}
}

View File

@ -0,0 +1,123 @@
using CaseAccountingContracts.BindingModels;
using CaseAccountingContracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
namespace CaseAccountingProviderView.Controllers
{
public class DealController : Controller
{
public IActionResult Create()
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
return View();
}
[HttpPost]
public void Create([FromBody] DealBindingModel dealModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
dealModel.UserId = APIUser.User.Id;
APIUser.PostRequest("api/deal/create", dealModel);
Response.Redirect("/Home/Deals");
}
public IActionResult Update(int id)
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Deal = APIUser.GetRequest<DealViewModel>($"api/deal/get?id={id}");
return View();
}
[HttpPost]
public void Update([FromBody] DealBindingModel dealModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
dealModel.UserId = APIUser.User.Id;
APIUser.PostRequest("api/deal/update", dealModel);
Response.Redirect("/Home/Deals");
}
public IActionResult AddDeal(int id)
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.DealId = id;
return View();
}
[HttpPost]
public void AddDeal([FromBody] DealBindingModel dealModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
APIUser.PostRequest("api/deal/update", dealModel);
}
public IActionResult Bind(int id)
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Deal = APIUser.GetRequest<DealViewModel>($"api/deal/get?id={id}");
return View();
}
[HttpPost]
public void Bind([FromBody] DealBindingModel dealModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
APIUser.PostRequest("api/deal/update", dealModel);
}
[HttpPost]
public void Delete(int id)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
APIUser.PostRequest($"api/deal/delete", new DealBindingModel() { Id = id });
Response.Redirect("/Home/Deals");
}
public List<DealViewModel> GetAllByUser()
{
if (APIUser.User == null)
{
return new();
}
List<DealViewModel>? dealModel = APIUser.GetRequest<List<DealViewModel>>($"api/deal/getallbyuser?userId={APIUser.User.Id}");
return dealModel ?? new();
}
public DealViewModel? Get(int id)
{
if (APIUser.User == null)
{
return new();
}
DealViewModel? dealModel = APIUser.GetRequest<DealViewModel>($"api/deal/get?id={id}");
return dealModel;
}
}
}

View File

@ -0,0 +1,123 @@
using CaseAccountingContracts.BindingModels;
using CaseAccountingContracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
namespace CaseAccountingProviderView.Controllers
{
public class HearingController : Controller
{
public IActionResult Create()
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
return View();
}
[HttpPost]
public void Create([FromBody] HearingBindingModel hearingModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
hearingModel.UserId = APIUser.User.Id;
APIUser.PostRequest("api/hearing/create", hearingModel);
Response.Redirect("/Home/Hearings");
}
public IActionResult Update(int id)
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Hearing = APIUser.GetRequest<HearingViewModel>($"api/hearing/get?id={id}");
return View();
}
[HttpPost]
public void Update([FromBody] HearingBindingModel hearingModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
hearingModel.UserId = APIUser.User.Id;
APIUser.PostRequest("api/hearing/update", hearingModel);
Response.Redirect("/Home/Hearings");
}
public IActionResult AddHearing(int id)
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.HearingId = id;
return View();
}
[HttpPost]
public void AddHearing([FromBody] HearingBindingModel hearingModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
APIUser.PostRequest("api/hearing/update", hearingModel);
}
public IActionResult Bind(int id)
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Hearing = APIUser.GetRequest<HearingViewModel>($"api/hearing/get?id={id}");
return View();
}
[HttpPost]
public void Bind([FromBody] HearingBindingModel hearingModel)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
APIUser.PostRequest("api/hearing/update", hearingModel);
}
[HttpPost]
public void Delete(int id)
{
if (APIUser.User == null)
{
throw new Exception("403");
}
APIUser.PostRequest($"api/hearing/delete", new HearingBindingModel() { Id = id });
Response.Redirect("/Home/Hearings");
}
public List<HearingViewModel> GetAllByUser()
{
if (APIUser.User == null)
{
return new();
}
List<HearingViewModel>? hearingModel = APIUser.GetRequest<List<HearingViewModel>>($"api/hearing/getallbyuser?userId={APIUser.User.Id}");
return hearingModel ?? new();
}
public HearingViewModel? Get(int id)
{
if (APIUser.User == null)
{
return new();
}
HearingViewModel? hearingModel = APIUser.GetRequest<HearingViewModel>($"api/hearing/get?id={id}");
return hearingModel;
}
}
}

View File

@ -1,4 +1,7 @@
using CaseAccountingProviderView.Models; using CaseAccountingContracts.BindingModels;
using CaseAccountingContracts.ViewModels;
using CaseAccountingDataModels.Enum;
using CaseAccountingProviderView.Models;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System.Diagnostics; using System.Diagnostics;
@ -15,14 +18,95 @@ namespace CaseAccountingProviderView.Controllers
public IActionResult Index() public IActionResult Index()
{ {
if (APIUser.User == null)
{
return Redirect("~/Home/Login");
}
return View(); return View();
} }
public IActionResult Privacy() public IActionResult Login()
{ {
return View(); return View();
} }
public IActionResult Registration()
{
return View();
}
[HttpPost]
public void Login(string login, string password)
{
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
{
throw new Exception("Введите логин и пароль");
}
APIUser.User = APIUser.GetRequest<UserViewModel>($"api/user/login?login={login}&password={password}&role={Role.Provider}");
if (APIUser.User == null)
{
throw new Exception("Неверный логин/пароль");
}
Response.Redirect("Index");
}
[HttpPost]
public void Registration(string login, string password)
{
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
{
throw new Exception("Введите логин и пароль");
}
APIUser.PostRequest("api/user/register", new UserBindingModel
{
Login = login,
Password = password,
Role = Role.Provider
});
Response.Redirect("Login");
return;
}
public IActionResult Cases()
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
/*if (page == 0)
{
page = 1;
}*/
ViewBag.Cases = APIUser.GetRequest<List<CaseViewModel>>
($"api/case/getallbyuser?userId={APIUser.User.Id}");
/*ViewBag.Page = page;
ViewBag.NumberOfPages = APIUser.GetRequest<int>
($"api/student/getnumberofpages?userId={APIUser.User.Id}");*/
return View();
}
public IActionResult Deals()
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Deals = APIUser.GetRequest<List<DealViewModel>>
($"api/deal/getallbyuser?userId={APIUser.User.Id}");
return View();
}
public IActionResult Hearings()
{
if (APIUser.User == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Hearings = APIUser.GetRequest<List<HearingViewModel>>
($"api/hearing/getallbyuser?userId={APIUser.User.Id}");
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error() public IActionResult Error()
{ {

View File

@ -1,3 +1,5 @@
using CaseAccountingProviderView;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
// Add services to the container. // Add services to the container.
@ -5,6 +7,8 @@ builder.Services.AddControllersWithViews();
var app = builder.Build(); var app = builder.Build();
APIUser.Connect(builder.Configuration);
// Configure the HTTP request pipeline. // Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment()) if (!app.Environment.IsDevelopment())
{ {

View File

@ -0,0 +1,32 @@
@{
ViewData["Title"] = "Дело";
}
<h4 class="fw-bold">Создание дела</h4>
<div id="error-div-shell" class="error-div-shell mb-2">
<div>
<p id="error-p" class="error-p"></p>
</div>
</div>
<p class="mb-0">Название:</p>
<input type="text" id="name-input" name="name" class="form-control mb-3" />
<p class="mb-0">Истец:</p>
<input type="text" id="applicant-input" name="applicant" class="form-control mb-3" />
<p class="mb-0">Ответчик:</p>
<input type="text" id="defendant-input" name="defendant" class="form-control mb-3" />
<p class="mb-0">Дата составления:</p>
<input type="date" id="date-input" name="date" class="form-control mb-3" />
<p class="mb-0">Примечание:</p>
<input type="text" id="annotation-input" name="annotation" class="form-control mb-3" />
<p class="mb-0">Специализация:</p>
<select id="specialization-select" name="specialization" class="form-control mb-3">
<option></option>
</select>
<button id="create-button" type="button" class="button-primary text-button">
Создать
</button>
<script src="~/js/case/case-create.js" asp-append-version="true"></script>

View File

@ -0,0 +1,43 @@
@{
ViewData["Title"] = "Дело";
}
@{
<h4 class="fw-bold" id="vb-id" data-id="@ViewBag.Case.Id">Изменение дела</h4>
if (ViewBag.Case == null)
{
<h3 class="display-4">Войдите в аккаунт</h3>
return;
}
<div id="error-div-shell" class="error-div-shell mb-2">
<div>
<p id="error-p" class="error-p"></p>
</div>
</div>
<p class="mb-0">Название:</p>
<input type="text" id="name-input" name="name" class="form-control mb-3" />
<p class="mb-0">Истец:</p>
<input type="text" id="applicant-input" name="applicant" class="form-control mb-3" />
<p class="mb-0">Ответчик:</p>
<input type="text" id="defendant-input" name="defendant" class="form-control mb-3" />
<p class="mb-0">Дата составления:</p>
<input type="date" id="date-input" name="date" class="form-control mb-3" />
<p class="mb-0">Примечание:</p>
<input type="text" id="annotation-input" name="annotation" class="form-control mb-3" />
<p class="mb-0">Специализация:</p>
<select id="specialization-select" name="specialization" class="form-control mb-3">
<option></option>
</select>
<button id="update-button" type="button" class="button-primary text-button">
Обновить
</button>
}
<script src="~/js/case/case-update.js" asp-append-version="true"></script>

View File

@ -0,0 +1,24 @@
@{
ViewData["Title"] = "Договор";
}
<h4 class="fw-bold">Создание договора</h4>
<div id="error-div-shell" class="error-div-shell mb-2">
<div>
<p id="error-p" class="error-p"></p>
</div>
</div>
<p class="mb-0">Объект договора:</p>
<input type="text" id="subject-input" name="subject" class="form-control mb-3" />
<p class="mb-0">Обязаности:</p>
<input type="text" id="responsibilities-input" name="responsibilities" class="form-control mb-3" />
<p class="mb-0">Дата составления:</p>
<input type="date" id="date-input" name="date" class="form-control mb-3" />
<button id="create-button" type="button" class="button-primary text-button">
Создать
</button>
<script src="~/js/deal/deal-create.js" asp-append-version="true"></script>

View File

@ -0,0 +1,34 @@
@{
ViewData["Title"] = "Договор";
}
@{
<h4 class="fw-bold" id="vb-id" data-id="@ViewBag.Deal.Id">Изменение договора</h4>
if (ViewBag.Deal == null)
{
<h3 class="display-4">Войдите в аккаунт</h3>
return;
}
<div id="error-div-shell" class="error-div-shell mb-2">
<div>
<p id="error-p" class="error-p"></p>
</div>
</div>
<p class="mb-0">Объект договора:</p>
<input type="text" id="subject-input" name="subject" class="form-control mb-3" />
<p class="mb-0">Обязаности:</p>
<input type="text" id="responsibilities-input" name="responsibilities" class="form-control mb-3" />
<p class="mb-0">Дата составления:</p>
<input type="date" id="date-input" name="date" class="form-control mb-3" />
<button id="update-button" type="button" class="button-primary text-button">
Обновить
</button>
}
<script src="~/js/deal/deal-update.js" asp-append-version="true"></script>

View File

@ -0,0 +1,26 @@
@{
ViewData["Title"] = "Слушание";
}
<h4 class="fw-bold">Создание слушания</h4>
<div id="error-div-shell" class="error-div-shell mb-2">
<div>
<p id="error-p" class="error-p"></p>
</div>
</div>
<p class="mb-0">Информация по слушанию:</p>
<input type="text" id="information-input" name="information" class="form-control mb-3" />
<p class="mb-0">Дата проведения:</p>
<input type="date" id="date-input" name="date" class="form-control mb-3" />
<p class="mb-0">Дело:</p>
<select id="case-select" name="case" class="form-control mb-3">
<option></option>
</select>
<button id="create-button" type="button" class="button-primary text-button">
Создать
</button>
<script src="~/js/hearing/hearing-create.js" asp-append-version="true"></script>

View File

@ -0,0 +1,36 @@
@{
ViewData["Title"] = "Слушание";
}
@{
<h4 class="fw-bold" id="vb-id" data-id="@ViewBag.Hearing.Id">Изменение слушания</h4>
if (ViewBag.Hearing == null)
{
<h3 class="display-4">Войдите в аккаунт</h3>
return;
}
<div id="error-div-shell" class="error-div-shell mb-2">
<div>
<p id="error-p" class="error-p"></p>
</div>
</div>
<p class="mb-0">Информация по слушанию:</p>
<input type="text" id="information-input" name="information" class="form-control mb-3" />
<p class="mb-0">Дата проведения:</p>
<input type="date" id="date-input" name="date" class="form-control mb-3" />
<p class="mb-0">Дело:</p>
<select id="case-select" name="case" class="form-control mb-3">
<option></option>
</select>
<button id="update-button" type="button" class="button-primary text-button">
Обновить
</button>
}
<script src="~/js/hearing/hearing-update.js" asp-append-version="true"></script>

View File

@ -0,0 +1,89 @@
@{
ViewData["Title"] = "Дела";
}
<div class="text-center">
<h1 class="display-4">Дела</h1>
</div>
<div class="text-center">
@{
if (ViewBag.Cases == null)
{
<h3 class="display-4">Войдите в аккаунт</h3>
return;
}
<div>
<a class="btn btn-success" asp-controller="Case" asp-action="Create">Создать дело</a>
</div>
<table class="table">
<thead>
<tr>
<th>
Номер Дела
</th>
<th>
Название
</th>
<th>
Истец
</th>
<th>
Ответчик
</th>
<th>
Примечание
</th>
<th>
Дата оформления
</th>
<th>
Специализация
</th>
<th>
Изменить запись
</th>
<th>
Удалить запись
</th>
</tr>
</thead>
<tbody>
@foreach (var item in ViewBag.Cases)
{
<tr class="d-table-row">
<td>
@item.Id
</td>
<td>
@item.Name
</td>
<td>
@item.Applicant
</td>
<td>
@item.Defendant
</td>
<td>
@item.Annotation
</td>
<td>
@item.Date.ToString("yyyy-MM-dd")
</td>
<td>
@item.Specialization
</td>
<td>
<a id="update-button-@item.Id" class="btn btn-warning" asp-controller="Case" asp-action="Update" asp-route-id="@item.Id">Изменить</a>
</td>
<td>
<a id="remove-button-@item.Id" class="btn btn-danger remove-btn" data-id="@item.Id">Удалить</a>
</td>
</tr>
}
</tbody>
</table>
}
</div>
<script src="~/js/case/cases.js" asp-append-version="true"></script>

View File

@ -0,0 +1,65 @@
@{
ViewData["Title"] = "Договора";
}
<div class="text-center">
<h1 class="display-4">Договора</h1>
</div>
<div class="text-center">
@{
if (ViewBag.Deals == null)
{
<h3 class="display-4">Войдите в аккаунт</h3>
return;
}
<div>
<a class="btn btn-success" asp-controller="Deal" asp-action="Create">Создать дело</a>
</div>
<table class="table">
<thead>
<tr>
<th>
Предмет договора
</th>
<th>
Обязанности
</th>
<th>
Дата составления
</th>
<th>
Изменить запись
</th>
<th>
Удалить запись
</th>
</tr>
</thead>
<tbody>
@foreach (var item in ViewBag.Deals)
{
<tr class="d-table-row">
<td>
@item.Subject
</td>
<td>
@item.Responsibilities
</td>
<td>
@item.Date.ToString("yyyy-MM-dd")
</td>
<td>
<a id="update-button-@item.Id" class="btn btn-warning" asp-controller="Deal" asp-action="Update" asp-route-id="@item.Id">Изменить</a>
</td>
<td>
<a id="remove-button-@item.Id" class="btn btn-danger remove-btn" data-id="@item.Id">Удалить</a>
</td>
</tr>
}
</tbody>
</table>
}
</div>
<script src="~/js/deal/deals.js" asp-append-version="true"></script>

View File

@ -0,0 +1,71 @@
@{
ViewData["Title"] = "Слушания";
}
<div class="text-center">
<h1 class="display-4">Слушания</h1>
</div>
<div class="text-center">
@{
if (ViewBag.Hearings == null)
{
<h3 class="display-4">Войдите в аккаунт</h3>
return;
}
<div>
<a class="btn btn-success" asp-controller="Hearing" asp-action="Create">Создать дело</a>
</div>
<table class="table">
<thead>
<tr>
<th>
Номер
</th>
<th>
Информация
</th>
<th>
Номер Дела
</th>
<th>
Дата слушания
</th>
<th>
Изменить запись
</th>
<th>
Удалить запись
</th>
</tr>
</thead>
<tbody>
@foreach (var item in ViewBag.Hearings)
{
<tr class="d-table-row">
<td>
@item.Id
</td>
<td>
@item.Information
</td>
<td>
@item.CaseId
</td>
<td>
@item.Date.ToString("yyyy-MM-dd")
</td>
<td>
<a id="update-button-@item.Id" class="btn btn-warning" asp-controller="Hearing" asp-action="Update" asp-route-id="@item.Id">Изменить</a>
</td>
<td>
<a id="remove-button-@item.Id" class="btn btn-danger remove-btn" data-id="@item.Id">Удалить</a>
</td>
</tr>
}
</tbody>
</table>
}
</div>
<script src="~/js/hearing/hearings.js" asp-append-version="true"></script>

View File

@ -1,8 +1,7 @@
@{ @{
ViewData["Title"] = "Home Page"; ViewData["Title"] = "Домашняя сраница";
} }
<div class="text-center"> <div class="text-center">
<h1 class="display-4">Welcome</h1> <h1>Добро пожаловать в курсовую работу!!!</h1>
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
</div> </div>

View File

@ -0,0 +1,27 @@
@{
ViewData["Title"] = "Вход";
}
<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="login" /></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8"><input type="password" name="password" /></div>
</div>
<div class="row">
<div class="col-8">
<a class="nav-link text-primary" asp-area="" asp-controller="Home" asp-action="Registration">
Нет аккаунта?
</a>
</div>
<div class="col-4">
<input type="submit" value="Войти" class="btn btn-info" />
</div>
</div>
</form>

View File

@ -1,6 +0,0 @@
@{
ViewData["Title"] = "Privacy Policy";
}
<h1>@ViewData["Title"]</h1>
<p>Use this page to detail your site's privacy policy.</p>

View File

@ -0,0 +1,27 @@
@{
ViewData["Title"] = "Регистрация";
}
<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="email" name="login" /></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>
<div class="col-8"><input type="password" name="password" /></div>
</div>
<div class="row">
<div class="col-8">
<a class="nav-link text-primary" asp-area="" asp-controller="Home" asp-action="Login">
Есть аккаунт?
</a>
</div>
<div class="col-4">
<input type="submit" value="Регистрация" class="btn btn-info" />
</div>
</div>
</form>

View File

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="ru">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
@ -10,22 +10,18 @@
</head> </head>
<body> <body>
<header> <header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3"> <nav class="navbar navbar-expand-lg bg-body-tertiary bg-primary" data-bs-theme="dark">
<div class="container-fluid"> <div class="container-fluid">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">CaseAccountingProviderView</a> <a class="navbar-brand" asp-area="" asp-controller="Home" aspaction="Index">Юридическая фирма "Вас обманут"</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent" <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between"> <div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<ul class="navbar-nav flex-grow-1"> <div class="navbar-nav">
<li class="nav-item"> <a class="nav-link" asp-area="" asp-controller="Home" asp-action="Cases">Дела</a>
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a> <a class="nav-link" asp-area="" asp-controller="Home" asp-action="Deals">Договора</a>
</li> <a class="nav-link" asp-area="" asp-controller="Home" asp-action="Hearings">Слушания</a>
<li class="nav-item"> </div>
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</li>
</ul>
</div> </div>
</div> </div>
</nav> </nav>
@ -35,12 +31,6 @@
@RenderBody() @RenderBody()
</main> </main>
</div> </div>
<footer class="border-top footer text-muted">
<div class="container">
&copy; 2023 - CaseAccountingProviderView - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script> <script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script> <script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script> <script src="~/js/site.js" asp-append-version="true"></script>

View File

@ -5,5 +5,6 @@
"Microsoft.AspNetCore": "Warning" "Microsoft.AspNetCore": "Warning"
} }
}, },
"AllowedHosts": "*" "AllowedHosts": "*",
"IPAddress": "http://localhost:5146"
} }

View File

@ -0,0 +1,69 @@
const createBtn = document.getElementById("create-button");
const nameInput = document.getElementById("name-input");
const applicantInput = document.getElementById("applicant-input");
const defendantInput = document.getElementById("defendant-input");
const annotationInput = document.getElementById("annotation-input");
const dateInput = document.getElementById("date-input");
const specializationSelect = document.getElementById("specialization-select");
var specializations = [];
window.addEventListener("load", async () => {
try {
const specializationsResponse = await $.ajax({
url: `/specialization/getall`,
type: "GET",
contentType: "json"
});
specializations = specializationsResponse;
specializations.forEach((specialization) => {
const option = document.createElement("option");
option.value = specialization.id;
option.innerHTML = specialization.name;
specializationSelect.appendChild(option);
specializationSelect.selectedIndex = -1;
});
} catch (error) {
console.error(error);
}
});
createBtn.addEventListener("click", () => {
if (!correctData()) {
return;
}
if (!validate()) {
return;
}
});
const correctData = function () {
return true;
};
const validate = function () {
return true;
};
createBtn.addEventListener("click", () => {
let caseModel = {
"Name": nameInput.value,
"Applicant": applicantInput.value,
"Defendant": defendantInput.value,
"Date": new Date(dateInput.value),
"Annotation": annotationInput.value,
"SpecializationId": parseInt(specializationSelect.value),
};
console.log(caseModel)
$.ajax({
url: "/case/create",
type: "POST",
contentType: "application/json",
data: JSON.stringify(caseModel)
}).done(() => {
window.location.href = "/Home/Cases";
});
});

View File

@ -0,0 +1,71 @@
const updateBtn = document.getElementById("update-button");
const nameInput = document.getElementById("name-input");
const applicantInput = document.getElementById("applicant-input");
const defendantInput = document.getElementById("defendant-input");
const annotationInput = document.getElementById("annotation-input");
const dateInput = document.getElementById("date-input");
const specializationSelect = document.getElementById("specialization-select");
const caseId = document.getElementById("vb-id").dataset.id;
var specializations = [];
window.addEventListener("load", async () => {
try {
const specializationsResponse = await $.ajax({
url: `/specialization/getall`,
type: "GET",
contentType: "json"
});
specializations = specializationsResponse;
specializations.forEach((specialization) => {
const option = document.createElement("option");
option.value = specialization.id;
option.innerHTML = specialization.name;
specializationSelect.appendChild(option);
specializationSelect.selectedIndex = -1;
});
} catch (error) {
console.error(error);
}
});
updateBtn.addEventListener("click", () => {
if (!correctData()) {
return;
}
if (!validate()) {
return;
}
});
const correctData = function () {
return true;
};
const validate = function () {
return true;
};
updateBtn.addEventListener("click", () => {
let caseModel = {
"Id": parseInt(caseId),
"Name": nameInput.value,
"Applicant": applicantInput.value,
"Defendant": defendantInput.value,
"Date": new Date(dateInput.value),
"Annotation": annotationInput.value,
"SpecializationId": parseInt(specializationSelect.value),
};
console.log(caseModel)
$.ajax({
url: "/case/update",
type: "POST",
contentType: "application/json",
data: JSON.stringify(caseModel)
}).done(() => {
window.location.href = "/Home/Cases";
});
});

View File

@ -0,0 +1,20 @@
const removeButtons = document.querySelectorAll(".remove-btn");
console.log(removeButtons)
removeButtons.forEach(function (button) {
button.addEventListener("click", function (event) {
var id = this.dataset.id;
console.log(id)
var result = confirm("Вы уверены, что хотите удалить эту запись?");
if (result) {
$.ajax({
url: "/case/delete",
type: "POST",
data: { Id: id }
}).done(() => {
window.location.reload();
});
}
});
});

View File

@ -0,0 +1,40 @@
const createBtn = document.getElementById("create-button");
const subjectInput = document.getElementById("subject-input");
const responsibilitiesInput = document.getElementById("responsibilities-input");
const dateInput = document.getElementById("date-input");
createBtn.addEventListener("click", () => {
if (!correctData()) {
return;
}
if (!validate()) {
return;
}
});
const correctData = function () {
return true;
};
const validate = function () {
return true;
};
createBtn.addEventListener("click", () => {
let dealModel = {
"Subject": subjectInput.value,
"Responsibilities": responsibilitiesInput.value,
"Date": new Date(dateInput.value)
};
console.log(dealModel)
$.ajax({
url: "/deal/create",
type: "POST",
contentType: "application/json",
data: JSON.stringify(dealModel)
}).done(() => {
window.location.href = "/Home/Deals";
});
});

View File

@ -0,0 +1,42 @@
const updateBtn = document.getElementById("update-button");
const subjectInput = document.getElementById("subject-input");
const responsibilitiesInput = document.getElementById("responsibilities-input");
const dateInput = document.getElementById("date-input");
const dealId = document.getElementById("vb-id").dataset.id;
updateBtn.addEventListener("click", () => {
if (!correctData()) {
return;
}
if (!validate()) {
return;
}
});
const correctData = function () {
return true;
};
const validate = function () {
return true;
};
updateBtn.addEventListener("click", () => {
let dealModel = {
"Id": parseInt(dealId),
"Subject": subjectInput.value,
"Responsibilities": responsibilitiesInput.value,
"Date": new Date(dateInput.value)
};
console.log(dealModel)
$.ajax({
url: "/deal/update",
type: "POST",
contentType: "application/json",
data: JSON.stringify(dealModel)
}).done(() => {
window.location.href = "/Home/Deals";
});
});

View File

@ -0,0 +1,20 @@
const removeButtons = document.querySelectorAll(".remove-btn");
console.log(removeButtons)
removeButtons.forEach(function (button) {
button.addEventListener("click", function (event) {
var id = this.dataset.id;
console.log(id)
var result = confirm("Вы уверены, что хотите удалить эту запись?");
if (result) {
$.ajax({
url: "/deal/delete",
type: "POST",
data: { Id: id }
}).done(() => {
window.location.reload();
});
}
});
});

View File

@ -0,0 +1,40 @@
const createBtn = document.getElementById("create-button");
const informationInput = document.getElementById("information-input");
const dateInput = document.getElementById("date-input");
const caseSelect = document.getElementById("case-select");
createBtn.addEventListener("click", () => {
if (!correctData()) {
return;
}
if (!validate()) {
return;
}
});
const correctData = function () {
return true;
};
const validate = function () {
return true;
};
createBtn.addEventListener("click", () => {
let hearingModel = {
"Information": informationInput.value,
"CaseId": parseInt(caseSelect.value),
"Date": new Date(dateInput.value)
};
console.log(dealModel)
$.ajax({
url: "/hearing/create",
type: "POST",
contentType: "application/json",
data: JSON.stringify(hearingModel)
}).done(() => {
window.location.href = "/Home/Hearings";
});
});

View File

@ -0,0 +1,42 @@
const updateBtn = document.getElementById("update-button");
const informationInput = document.getElementById("information-input");
const dateInput = document.getElementById("date-input");
const caseSelect = document.getElementById("case-select");
const hearingId = document.getElementById("vb-id").dataset.id;
updateBtn.addEventListener("click", () => {
if (!correctData()) {
return;
}
if (!validate()) {
return;
}
});
const correctData = function () {
return true;
};
const validate = function () {
return true;
};
updateBtn.addEventListener("click", () => {
let hearingModel = {
"Id": parseInt(hearingId),
"Information": informationInput.value,
"CaseId": parseInt(caseSelect.value),
"Date": new Date(dateInput.value)
};
console.log(hearingModel)
$.ajax({
url: "/hearing/update",
type: "POST",
contentType: "application/json",
data: JSON.stringify(hearingModel)
}).done(() => {
window.location.href = "/Home/Hearings";
});
});

View File

@ -0,0 +1,20 @@
const removeButtons = document.querySelectorAll(".remove-btn");
console.log(removeButtons)
removeButtons.forEach(function (button) {
button.addEventListener("click", function (event) {
var id = this.dataset.id;
console.log(id)
var result = confirm("Вы уверены, что хотите удалить эту запись?");
if (result) {
$.ajax({
url: "/hearing/delete",
type: "POST",
data: { Id: id }
}).done(() => {
window.location.reload();
});
}
});
});