Договора работают
This commit is contained in:
parent
82028c2fdd
commit
15afb389c7
@ -127,14 +127,13 @@ namespace CaseAccountingDataBaseImplement.Implements
|
||||
|
||||
public CaseViewModel? Insert(CaseBindingModel model)
|
||||
{
|
||||
var newCase = Case.Create(model);
|
||||
using var context = new CaseAccountingDatabase();
|
||||
var newCase = Case.Create(context, model);
|
||||
if (newCase == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new CaseAccountingDatabase();
|
||||
|
||||
context.Cases.Add(newCase);
|
||||
context.SaveChanges();
|
||||
return context.Cases
|
||||
@ -162,6 +161,7 @@ namespace CaseAccountingDataBaseImplement.Implements
|
||||
_case.Update(model);
|
||||
context.SaveChanges();
|
||||
_case.UpdateLawyers(context, model);
|
||||
transaction.Commit();
|
||||
return _case.GetViewModel;
|
||||
}
|
||||
catch
|
||||
|
@ -119,6 +119,7 @@ namespace CaseAccountingDataBaseImplement.Implements
|
||||
contract.Update(model);
|
||||
context.SaveChanges();
|
||||
contract.UpdateDeals(context, model);
|
||||
transaction.Commit();
|
||||
return contract.GetViewModel;
|
||||
}
|
||||
catch
|
||||
|
@ -86,14 +86,13 @@ namespace CaseAccountingDataBaseImplement.Implements
|
||||
|
||||
public DealViewModel? Insert(DealBindingModel model)
|
||||
{
|
||||
var newDeal = Deal.Create(model);
|
||||
using var context = new CaseAccountingDatabase();
|
||||
var newDeal = Deal.Create(context, model);
|
||||
if (newDeal == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new CaseAccountingDatabase();
|
||||
|
||||
context.Deals.Add(newDeal);
|
||||
context.SaveChanges();
|
||||
return context.Deals
|
||||
@ -119,6 +118,7 @@ namespace CaseAccountingDataBaseImplement.Implements
|
||||
deal.Update(model);
|
||||
context.SaveChanges();
|
||||
deal.UpdateCases(context, model);
|
||||
transaction.Commit();
|
||||
return deal.GetViewModel;
|
||||
}
|
||||
catch
|
||||
|
@ -100,14 +100,13 @@ namespace CaseAccountingDataBaseImplement.Implements
|
||||
|
||||
public HearingViewModel? Insert(HearingBindingModel model)
|
||||
{
|
||||
var newHearing = Hearing.Create(model);
|
||||
using var context = new CaseAccountingDatabase();
|
||||
var newHearing = Hearing.Create(context, model);
|
||||
if (newHearing == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new CaseAccountingDatabase();
|
||||
|
||||
context.Hearings.Add(newHearing);
|
||||
context.SaveChanges();
|
||||
return context.Hearings
|
||||
|
@ -126,6 +126,7 @@ namespace CaseAccountingDataBaseImplement.Implements
|
||||
lawyer.Update(model);
|
||||
context.SaveChanges();
|
||||
lawyer.UpdateContracts(context, model);
|
||||
transaction.Commit();
|
||||
return lawyer.GetViewModel;
|
||||
}
|
||||
catch
|
||||
|
@ -18,7 +18,6 @@ namespace CaseAccountingDataBaseImplement.Implements
|
||||
{
|
||||
using var context = new CaseAccountingDatabase();
|
||||
var element = context.Users
|
||||
.Include(x => x.Role)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element == null)
|
||||
{
|
||||
@ -31,14 +30,12 @@ namespace CaseAccountingDataBaseImplement.Implements
|
||||
|
||||
public UserViewModel? GetElement(UserSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new CaseAccountingDatabase();
|
||||
return context.Users
|
||||
.Include(x => x.Role)
|
||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
||||
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id) ||
|
||||
(!string.IsNullOrEmpty(model.Login) && x.Login == model.Login &&
|
||||
!string.IsNullOrEmpty(model.Password) && x.Password == model.Password &&
|
||||
x.Role == model.Role))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
@ -48,7 +45,6 @@ namespace CaseAccountingDataBaseImplement.Implements
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return context.Users
|
||||
.Include(x => x.Role)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
@ -63,7 +59,6 @@ namespace CaseAccountingDataBaseImplement.Implements
|
||||
{
|
||||
using var context = new CaseAccountingDatabase();
|
||||
return context.Users
|
||||
.Include(x => x.Role)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
@ -81,7 +76,6 @@ namespace CaseAccountingDataBaseImplement.Implements
|
||||
context.Users.Add(newUser);
|
||||
context.SaveChanges();
|
||||
return context.Users
|
||||
.Include(x => x.Role)
|
||||
.FirstOrDefault(x => x.Id == newUser.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
@ -91,7 +85,6 @@ namespace CaseAccountingDataBaseImplement.Implements
|
||||
using var context = new CaseAccountingDatabase();
|
||||
|
||||
var user = context.Users
|
||||
.Include(x => x.Role)
|
||||
.FirstOrDefault(x => x.Id == model.Id);
|
||||
|
||||
if (user == null)
|
||||
@ -101,7 +94,6 @@ namespace CaseAccountingDataBaseImplement.Implements
|
||||
user.Update(model);
|
||||
context.SaveChanges();
|
||||
return context.Users
|
||||
.Include(x => x.Role)
|
||||
.FirstOrDefault(x => x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ namespace CaseAccountingDataBaseImplement.Models
|
||||
[ForeignKey("CaseId")]
|
||||
public virtual List<CaseDeal> Deals { get; set; } = new();
|
||||
|
||||
public static Case? Create(CaseBindingModel model)
|
||||
public static Case? Create(CaseAccountingDatabase context, CaseBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -81,8 +81,10 @@ namespace CaseAccountingDataBaseImplement.Models
|
||||
Annotation = model.Annotation,
|
||||
Date = model.Date,
|
||||
SpecializationId = model.SpecializationId,
|
||||
UserId = model.UserId
|
||||
};
|
||||
Specialization = context.Specializations.FirstOrDefault( x => x.Id == model.SpecializationId) ?? throw new Exception("Specialization не существует"),
|
||||
UserId = model.UserId,
|
||||
User = context.Users.FirstOrDefault(x => x.Id == model.UserId) ?? throw new Exception("User не существует")
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(CaseBindingModel model)
|
||||
|
@ -51,7 +51,7 @@ namespace CaseAccountingDataBaseImplement.Models
|
||||
[ForeignKey("DealId")]
|
||||
public virtual List<DealContract> Contracts { get; set; } = new();
|
||||
|
||||
public static Deal? Create(DealBindingModel? model)
|
||||
public static Deal? Create(CaseAccountingDatabase context, DealBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -64,6 +64,7 @@ namespace CaseAccountingDataBaseImplement.Models
|
||||
Responsibilities = model.Responsibilities,
|
||||
Date = model.Date,
|
||||
UserId = model.UserId,
|
||||
User = context.Users.FirstOrDefault(x => x.Id == model.UserId) ?? throw new Exception("User не существует")
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ namespace CaseAccountingDataBaseImplement.Models
|
||||
public int UserId { get; set; }
|
||||
public virtual User User { get; set; } = new();
|
||||
|
||||
public static Hearing? Create (HearingBindingModel? model)
|
||||
public static Hearing? Create (CaseAccountingDatabase context, HearingBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -41,7 +41,9 @@ namespace CaseAccountingDataBaseImplement.Models
|
||||
Information = model.Information,
|
||||
Date = model.Date,
|
||||
CaseId = model.CaseId,
|
||||
UserId = model.UserId
|
||||
Case = context.Cases.FirstOrDefault(x => x.Id == model.CaseId) ?? throw new Exception("Case не существует"),
|
||||
UserId = model.UserId,
|
||||
User = context.Users.FirstOrDefault(x => x.Id == model.UserId) ?? throw new Exception("User не существует")
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -14,4 +14,9 @@
|
||||
<ProjectReference Include="..\CaseAccountingContracts\CaseAccountingContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="wwwroot\js\deal\" />
|
||||
<Folder Include="wwwroot\js\hearing\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -25,7 +25,7 @@
|
||||
<option></option>
|
||||
</select>
|
||||
|
||||
<button id="create-button" type="button" class="button-primary text-button">
|
||||
<button id="create-button" type="button" class="btn btn-primary text-button">
|
||||
Создать
|
||||
</button>
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
<option></option>
|
||||
</select>
|
||||
|
||||
<button id="update-button" type="button" class="button-primary text-button">
|
||||
<button id="update-button" type="button" class="btn btn-primary text-button">
|
||||
Обновить
|
||||
</button>
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
<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 id="create-button" type="button" class="btn btn-primary text-button">
|
||||
Создать
|
||||
</button>
|
||||
|
||||
|
@ -7,10 +7,10 @@
|
||||
<h4 class="fw-bold" id="vb-id" data-id="@ViewBag.Deal.Id">Изменение договора</h4>
|
||||
|
||||
if (ViewBag.Deal == null)
|
||||
{
|
||||
<h3 class="display-4">Войдите в аккаунт</h3>
|
||||
return;
|
||||
}
|
||||
{
|
||||
<h3 class="display-4">Войдите в аккаунт</h3>
|
||||
return;
|
||||
}
|
||||
|
||||
<div id="error-div-shell" class="error-div-shell mb-2">
|
||||
<div>
|
||||
@ -25,7 +25,7 @@
|
||||
<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 id="update-button" type="button" class="btn btn-primary text-button">
|
||||
Обновить
|
||||
</button>
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
<option></option>
|
||||
</select>
|
||||
|
||||
<button id="create-button" type="button" class="button-primary text-button">
|
||||
<button id="create-button" type="button" class="btn btn-primary text-button">
|
||||
Создать
|
||||
</button>
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
<option></option>
|
||||
</select>
|
||||
|
||||
<button id="update-button" type="button" class="button-primary text-button">
|
||||
<button id="update-button" type="button" class="btn btn-primary text-button">
|
||||
Обновить
|
||||
</button>
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
return;
|
||||
}
|
||||
<div>
|
||||
<a class="btn btn-success" asp-controller="Case" asp-action="Create">Создать дело</a>
|
||||
<a class="btn btn-success" asp-controller="Case" asp-action="Create">Создать запись</a>
|
||||
</div>
|
||||
<table class="table">
|
||||
<thead>
|
||||
|
@ -14,7 +14,7 @@
|
||||
return;
|
||||
}
|
||||
<div>
|
||||
<a class="btn btn-success" asp-controller="Deal" asp-action="Create">Создать дело</a>
|
||||
<a class="btn btn-success" asp-controller="Deal" asp-action="Create">Создать запись</a>
|
||||
</div>
|
||||
<table class="table">
|
||||
<thead>
|
||||
|
@ -14,7 +14,7 @@
|
||||
return;
|
||||
}
|
||||
<div>
|
||||
<a class="btn btn-success" asp-controller="Hearing" asp-action="Create">Создать дело</a>
|
||||
<a class="btn btn-success" asp-controller="Hearing" asp-action="Create">Создать запись</a>
|
||||
</div>
|
||||
<table class="table">
|
||||
<thead>
|
||||
|
@ -11,16 +11,16 @@
|
||||
<body>
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-lg bg-body-tertiary bg-primary" data-bs-theme="dark">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" aspaction="Index">Юридическая фирма "Вас обманут"</a>
|
||||
<div class="container">
|
||||
<a class="navbar-brand text-white" asp-area="" asp-controller="Home" aspaction="Index">Юридическая фирма "Вас обманут"</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
|
||||
<div class="navbar-nav">
|
||||
<a class="nav-link" asp-area="" asp-controller="Home" asp-action="Cases">Дела</a>
|
||||
<a class="nav-link" asp-area="" asp-controller="Home" asp-action="Deals">Договора</a>
|
||||
<a class="nav-link" asp-area="" asp-controller="Home" asp-action="Hearings">Слушания</a>
|
||||
<a class="nav-link text-white" asp-area="" asp-controller="Home" asp-action="Cases">Дела</a>
|
||||
<a class="nav-link text-white" asp-area="" asp-controller="Home" asp-action="Deals">Договора</a>
|
||||
<a class="nav-link text-white" asp-area="" asp-controller="Home" asp-action="Hearings">Слушания</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -3,6 +3,29 @@ const informationInput = document.getElementById("information-input");
|
||||
const dateInput = document.getElementById("date-input");
|
||||
const caseSelect = document.getElementById("case-select");
|
||||
|
||||
var cases = [];
|
||||
|
||||
window.addEventListener("load", async () => {
|
||||
try {
|
||||
const casesResponse = await $.ajax({
|
||||
url: `/specialization/getall`,
|
||||
type: "GET",
|
||||
contentType: "json"
|
||||
});
|
||||
cases = casesResponse;
|
||||
|
||||
cases.forEach((element) => {
|
||||
const option = document.createElement("option");
|
||||
option.value = element.id;
|
||||
option.innerHTML = "Дело №" + element.id;
|
||||
caseSelect.appendChild(option);
|
||||
caseSelect.selectedIndex = -1;
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
|
||||
createBtn.addEventListener("click", () => {
|
||||
if (!correctData()) {
|
||||
return;
|
||||
|
@ -4,6 +4,29 @@ const dateInput = document.getElementById("date-input");
|
||||
const caseSelect = document.getElementById("case-select");
|
||||
const hearingId = document.getElementById("vb-id").dataset.id;
|
||||
|
||||
var cases = [];
|
||||
|
||||
window.addEventListener("load", async () => {
|
||||
try {
|
||||
const casesResponse = await $.ajax({
|
||||
url: `/specialization/getall`,
|
||||
type: "GET",
|
||||
contentType: "json"
|
||||
});
|
||||
cases = casesResponse;
|
||||
|
||||
cases.forEach((element) => {
|
||||
const option = document.createElement("option");
|
||||
option.value = element.id;
|
||||
option.innerHTML = "Дело №" + element.id;
|
||||
caseSelect.appendChild(option);
|
||||
caseSelect.selectedIndex = -1;
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
|
||||
updateBtn.addEventListener("click", () => {
|
||||
if (!correctData()) {
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user