This commit is contained in:
Софья Якобчук 2024-05-25 22:04:59 +04:00
commit 9dfc3a737d
18 changed files with 481 additions and 59 deletions

View File

@ -20,13 +20,13 @@ namespace LawCompanyDatabaseImplement.Implements
}
public List<CaseViewModel> GetFilteredList(CaseSearchModel model)
{
if (!model.DateFrom.HasValue && !model.DateTo.HasValue
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue
&& !model.ExecutorId.HasValue)
{
return new();
}
if (model.ExecutorId.HasValue)
if (model.ExecutorId.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
{
using var context = new LawCompanyDatabase();
return context.Cases
@ -35,13 +35,23 @@ namespace LawCompanyDatabaseImplement.Implements
.Select(x => x.GetViewModel)
.ToList();
}
else if (model.ExecutorId.HasValue)
{
using var context = new LawCompanyDatabase();
return context.Cases
.Include(x => x.Clients)
.ThenInclude(x => x.Client)
.Where(x => x.ExecutorId == model.ExecutorId)
.Select(x => x.GetViewModel)
.ToList();
}
else if (!model.DateFrom.HasValue || !model.DateTo.HasValue)
{
using var context = new LawCompanyDatabase();
return context.Cases.Include(x => x.CaseClients)
.Include(x => x.Clients).ThenInclude(x => x.Client)
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel).ToList()
.Select(x => x.GetViewModel)
.ToList();
}
else

View File

@ -22,11 +22,11 @@ namespace LawCompanyDatabaseImplement.Implements
public List<ConsultationViewModel> GetFilteredList(ConsultationSearchModel model)
{
if (!model.Id.HasValue && !model.GuarantorId.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue
&& !model.ConsultationDate.HasValue)
&& !model.ConsultationDate.HasValue && !model.CaseId.HasValue)
{
return new();
}
if (!model.GuarantorId.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
if (model.GuarantorId.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
{
using var context = new LawCompanyDatabase();
return context.Consultations
@ -38,14 +38,13 @@ namespace LawCompanyDatabaseImplement.Implements
.Select(x => x.GetViewModel)
.ToList();
}
if (!model.GuarantorId.HasValue)
else if (model.GuarantorId.HasValue)
{
using var context = new LawCompanyDatabase();
return context.Consultations
.Include(x => x.Lawyers)
.ThenInclude(x => x.Lawyer)
.Where(x => x.GuarantorId == model.GuarantorId)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}

View File

@ -15,7 +15,8 @@ namespace LawCompanyDatabaseImplement
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseSqlServer(@"Data Source=LAPTOP-6GNIALH9\SQLEXPRESS;Initial Catalog=LawCompanyDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
//optionsBuilder.UseSqlServer(@"Data Source=LAPTOP-6GNIALH9\SQLEXPRESS;Initial Catalog=LawCompanyDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-H8060U3\SQLEXPRESS;Initial Catalog=LawCompanyDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
}
base.OnConfiguring(optionsBuilder);
}

View File

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

View File

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

View File

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

View File

@ -1,6 +1,11 @@
using LawCompanyContracts.StoragesContracts;
using LawCompanyDatabaseImplement.Implements;
using LawCompanyGuarantorApp;
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,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="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,60 @@
@using LawCompanyContracts.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>
E-mail
</th>
<th>
Телефон
</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.Email)
</td>
<td>
@Html.DisplayFor(modelItem =>
item.Phone)
</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,59 @@
@using LawCompanyContracts.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>
E-mail
</th>
<th>
Телефон
</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.Email)
</td>
<td>
@Html.DisplayFor(modelItem =>
item.Phone)
</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>

View File

@ -130,12 +130,12 @@ namespace LawCompanyRestApi.Controllers
}
[HttpPost]
public void AddClientToCase(Tuple<CaseSearchModel, ClientViewModel> model)
public void AddClientToCase(Tuple<CaseSearchModel, int> model)
{
try
{
_logic.AddClientToCase(model.Item1, model.Item2);
var modelClient = _clientlogic.ReadElement(new ClientSearchModel { Id = model.Item2 });
if (modelClient != null) _logic.AddClientToCase(model.Item1, modelClient);
}
catch (Exception ex)
{