Починили Contracts, Specializations.
This commit is contained in:
parent
f3652285b9
commit
4bea770d99
@ -69,7 +69,7 @@ namespace CaseAccountingCustomerView.Controllers
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Lawyers = APIUser.GetRequest<List<LawyerViewModel>>
|
||||
($"api/lawyer/getmany?userId={APIUser.User.Id}");
|
||||
($"api/lawyer/getallbyuser?userId={APIUser.User.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ namespace CaseAccountingCustomerView.Controllers
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Specializations = APIUser.GetRequest<List<SpecializationViewModel>>
|
||||
($"api/specialization/getmany?userId={APIUser.User.Id}");
|
||||
($"api/specialization/getallbyuser?userId={APIUser.User.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ namespace CaseAccountingCustomerView.Controllers
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Contracts = APIUser.GetRequest<List<ContractViewModel>>
|
||||
($"api/contract/getmany?userId={APIUser.User.Id}");
|
||||
($"api/contract/getallbyuser?userId={APIUser.User.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
|
@ -21,4 +21,4 @@
|
||||
Создать
|
||||
</button>
|
||||
|
||||
<script src="~/js/contract/contract-create.js" asp-append-version="true"></script>
|
||||
<script src="~/js/Contracts/contract-create.js" asp-append-version="true"></script>
|
@ -31,4 +31,4 @@
|
||||
</button>
|
||||
}
|
||||
|
||||
<script src="~/js/contract/contract-update.js" asp-append-version="true"></script>
|
||||
<script src="~/js/Contracts/contract-update.js" asp-append-version="true"></script>
|
@ -0,0 +1,72 @@
|
||||
@using CaseAccountingContracts.ViewModels
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Контракты";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Контракты</h1>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (ViewBag.Contracts == null)
|
||||
{
|
||||
<h3 class="display-4">Войдите в аккаунт</h3>
|
||||
return;
|
||||
}
|
||||
<div>
|
||||
<a class="btn btn-secondary" asp-controller="Contracts" asp-action="Create">Добавить контракт</a>
|
||||
</div>
|
||||
<div class="d-flex mb-2 gap-1">
|
||||
<a href="/Home/Contracts" id="go-button" class="button-primary text-button">
|
||||
Перейти
|
||||
</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.Contracts)
|
||||
{
|
||||
<tr class="d-table-row">
|
||||
<td>
|
||||
@item.Service
|
||||
</td>
|
||||
<td>
|
||||
@item.Coast
|
||||
</td>
|
||||
<td>
|
||||
@item.Date
|
||||
</td>
|
||||
<td>
|
||||
<a id="update-button-@item.Id" class="btn btn-secondary" asp-controller="Contracts" asp-action="Update" asp-route-id="@item.Id">Изменить</a>
|
||||
</td>
|
||||
<td>
|
||||
<a id="remove-button-@item.Id" class="btn btn-secondary remove-btn" data-id="@item.Id">Удалить</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
|
||||
<script src="~/js/Contracts/contracts.js" asp-append-version="true"></script>
|
@ -18,15 +18,6 @@
|
||||
<div>
|
||||
<a class="btn btn-secondary" asp-controller="Lawyer" asp-action="Create">Добавить юриста</a>
|
||||
</div>
|
||||
<div class="d-flex mb-2 gap-1">
|
||||
<div class="input-group" style="width: auto;">
|
||||
<input id="page-input" type="number" min="1" value="@ViewBag.Page" max="@ViewBag.NumberOfPages" class="form-control" style="max-width: 5em">
|
||||
<span class="input-group-text">/ @ViewBag.NumberOfPages</span>
|
||||
</div>
|
||||
<a href="/Home/Lawyers?page=@ViewBag.Page" id="go-button" class="button-primary text-button">
|
||||
Перейти
|
||||
</a>
|
||||
</div>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -0,0 +1,60 @@
|
||||
@using CaseAccountingContracts.ViewModels
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Специализации";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Специализации</h1>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (ViewBag.Specializations == null)
|
||||
{
|
||||
<h3 class="display-4">Войдите в аккаунт</h3>
|
||||
return;
|
||||
}
|
||||
<div>
|
||||
<a class="btn btn-secondary" asp-controller="Specializations" asp-action="Create">Добавить специализацию</a>
|
||||
</div>
|
||||
<div class="d-flex mb-2 gap-1">
|
||||
<a href="/Home/Specializations" id="go-button" class="button-primary text-button">
|
||||
Перейти
|
||||
</a>
|
||||
</div>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Название
|
||||
</th>
|
||||
<th>
|
||||
Изменить запись
|
||||
</th>
|
||||
<th>
|
||||
Удалить запись
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in ViewBag.Specializations)
|
||||
{
|
||||
<tr class="d-table-row">
|
||||
<td>
|
||||
@item.Name
|
||||
</td>
|
||||
<td>
|
||||
<a id="update-button-@item.Id" class="btn btn-secondary" asp-controller="Specialization" asp-action="Update" asp-route-id="@item.Id">Изменить</a>
|
||||
</td>
|
||||
<td>
|
||||
<a id="remove-button-@item.Id" class="btn btn-secondary remove-btn" data-id="@item.Id">Удалить</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
|
||||
<script src="~/js/specialization/specializations.js" asp-append-version="true"></script>
|
@ -20,10 +20,19 @@
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Contracts">Контракты</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Lawyers">Юристы</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Specializations">Специализации</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="HearingLawyerList">Получить список</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="GetReport">Получить отчёт</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -54,4 +54,4 @@
|
||||
</div>
|
||||
}
|
||||
|
||||
<script src="~/js/specialization/specialization-add-student.js" asp-append-version="true"></script>
|
||||
<script src="~/js/Specializations/specialization-add-student.js" asp-append-version="true"></script>
|
@ -17,4 +17,4 @@
|
||||
Создать
|
||||
</button>
|
||||
|
||||
<script src="~/js/specialization/specialization-create.js" asp-append-version="true"></script>
|
||||
<script src="~/js/Specializations/specialization-create.js" asp-append-version="true"></script>
|
@ -27,4 +27,4 @@
|
||||
</button>
|
||||
}
|
||||
|
||||
<script src="~/js/specialization/specialization-update.js" asp-append-version="true"></script>
|
||||
<script src="~/js/Specializations/specialization-update.js" asp-append-version="true"></script>
|
@ -7,5 +7,5 @@
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
|
||||
"IPAddress": "http://localhost:5146/"
|
||||
"IPAddress": "http://localhost:5146"
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ createBtn.addEventListener("click", () => {
|
||||
};
|
||||
console.log(contract)
|
||||
$.ajax({
|
||||
url: "/contract/create",
|
||||
url: "/contracts/create",
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(contract)
|
||||
|
@ -21,15 +21,15 @@ const validate = function () {
|
||||
};
|
||||
|
||||
createBtn.addEventListener("click", () => {
|
||||
let specialization = {
|
||||
let specializationModel = {
|
||||
"Name": nameInput.value,
|
||||
};
|
||||
console.log(specialization)
|
||||
console.log(specializationModel)
|
||||
$.ajax({
|
||||
url: "/specialization/create",
|
||||
url: "/specializations/create",
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(specialization)
|
||||
data: JSON.stringify(specializationModel)
|
||||
}).done(() => {
|
||||
window.location.href = "/Home/Specializations";
|
||||
});
|
||||
|
@ -28,7 +28,7 @@ updateBtn.addEventListener("click", () => {
|
||||
};
|
||||
console.log(specialization)
|
||||
$.ajax({
|
||||
url: "/specialization/update",
|
||||
url: "/specializations/update",
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(specialization)
|
||||
|
@ -10,7 +10,7 @@ var specialization = null;
|
||||
window.addEventListener("load", async () => {
|
||||
try {
|
||||
const lawyersResponse = await $.ajax({
|
||||
url: `/lawyer/getallbyuserandspecialization?specialization=${specializationId}`,
|
||||
url: `/lawyers/getallbyuserandspecialization?specialization=${specializationId}`,
|
||||
type: "GET",
|
||||
contentType: "json"
|
||||
});
|
||||
@ -21,7 +21,7 @@ window.addEventListener("load", async () => {
|
||||
});
|
||||
|
||||
const specializationResponse = await $.ajax({
|
||||
url: `/specialization/get?id=${specializationId}`,
|
||||
url: `/specializations/get?id=${specializationId}`,
|
||||
type: 'GET',
|
||||
contentType: 'json'
|
||||
});
|
||||
@ -42,7 +42,7 @@ updateBtn.addEventListener("click", () => {
|
||||
lawyer.specializationId = specialization.id;
|
||||
|
||||
$.ajax({
|
||||
url: "/lawyer/update",
|
||||
url: "/lawyers/update",
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(lawyer)
|
||||
|
@ -8,7 +8,7 @@ removeButtons.forEach(function (button) {
|
||||
var result = confirm("Вы уверены, что хотите удалить эту запись?");
|
||||
if (result) {
|
||||
$.ajax({
|
||||
url: "/specialization/delete",
|
||||
url: "/specializations/delete",
|
||||
type: "POST",
|
||||
data: { Id: id }
|
||||
}).done(() => {
|
||||
|
@ -18,8 +18,8 @@ namespace CaseAccountingDataBaseImplement
|
||||
Host=localhost;
|
||||
Port=5432;
|
||||
Database=CaseAccountingDatabase;
|
||||
Username=courseuser;
|
||||
Password=courseuser");
|
||||
Username=postgres;
|
||||
Password=postgres");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
@ -86,14 +86,13 @@ namespace CaseAccountingDataBaseImplement.Implements
|
||||
|
||||
public ContractViewModel? Insert(ContractBindingModel model)
|
||||
{
|
||||
var newContract = Contract.Create(model);
|
||||
using var context = new CaseAccountingDatabase();
|
||||
var newContract = Contract.Create(context, model);
|
||||
if (newContract == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new CaseAccountingDatabase();
|
||||
|
||||
context.Contracts.Add(newContract);
|
||||
context.SaveChanges();
|
||||
return context.Contracts
|
||||
|
@ -91,13 +91,13 @@ namespace CaseAccountingDataBaseImplement.Implements
|
||||
|
||||
public LawyerViewModel? Insert(LawyerBindingModel model)
|
||||
{
|
||||
var newLawyer = Lawyer.Create(model);
|
||||
using var context = new CaseAccountingDatabase();
|
||||
var newLawyer = Lawyer.Create(context, model);
|
||||
if (newLawyer == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new CaseAccountingDatabase();
|
||||
|
||||
context.Lawyers.Add(newLawyer);
|
||||
context.SaveChanges();
|
||||
|
@ -85,14 +85,14 @@ namespace CaseAccountingDataBaseImplement.Implements
|
||||
|
||||
public SpecializationViewModel? Insert(SpecializationBindingModel model)
|
||||
{
|
||||
var newSpecialization = Specialization.Create(model);
|
||||
using var context = new CaseAccountingDatabase();
|
||||
|
||||
var newSpecialization = Specialization.Create(context, model);
|
||||
if (newSpecialization == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new CaseAccountingDatabase();
|
||||
|
||||
context.Specializations.Add(newSpecialization);
|
||||
context.SaveChanges();
|
||||
return context.Specializations
|
||||
|
@ -53,7 +53,7 @@ namespace CaseAccountingDataBaseImplement.Models
|
||||
}
|
||||
}
|
||||
|
||||
public static Contract? Create(ContractBindingModel? model)
|
||||
public static Contract? Create(CaseAccountingDatabase context, ContractBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -65,7 +65,8 @@ namespace CaseAccountingDataBaseImplement.Models
|
||||
Service = model.Service,
|
||||
Coast = model.Coast,
|
||||
Date = model.Date,
|
||||
UserId = model.UserId
|
||||
UserId = model.UserId,
|
||||
User = context.Users.FirstOrDefault(x => x.Id == model.UserId) ?? throw new Exception("Not found user")
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ namespace CaseAccountingDataBaseImplement.Models
|
||||
}
|
||||
}
|
||||
|
||||
public static Lawyer? Create(LawyerBindingModel? model)
|
||||
public static Lawyer? Create(CaseAccountingDatabase context, LawyerBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -71,7 +71,9 @@ namespace CaseAccountingDataBaseImplement.Models
|
||||
Patronymic = model.Patronymic,
|
||||
Experience = model.Experience,
|
||||
SpecializationId = model.SpecializationId,
|
||||
UserId = model.UserId
|
||||
Specialization = context.Specializations.FirstOrDefault(x => x.Id == model.SpecializationId) ?? throw new Exception("specialization not found"),
|
||||
UserId = model.UserId,
|
||||
User = context.Users.FirstOrDefault(x => x.Id == model.UserId) ?? throw new Exception("User not found")
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace CaseAccountingDataBaseImplement.Models
|
||||
[ForeignKey("SpecializationId")]
|
||||
public virtual List<Case> Cases { get; set; } = new();
|
||||
|
||||
public static Specialization? Create (SpecializationBindingModel? model)
|
||||
public static Specialization? Create (CaseAccountingDatabase context, SpecializationBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -41,6 +41,7 @@ namespace CaseAccountingDataBaseImplement.Models
|
||||
Id = model.Id,
|
||||
Name = model.Name,
|
||||
UserId = model.UserId,
|
||||
User = context.Users.FirstOrDefault(x => x.Id == model.UserId) ?? throw new Exception("User not found"),
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user