diff --git a/CaseAccounting/CaseAccountingCustomerView/Controllers/HomeController.cs b/CaseAccounting/CaseAccountingCustomerView/Controllers/HomeController.cs index 362ec19..da37694 100644 --- a/CaseAccounting/CaseAccountingCustomerView/Controllers/HomeController.cs +++ b/CaseAccounting/CaseAccountingCustomerView/Controllers/HomeController.cs @@ -69,7 +69,7 @@ namespace CaseAccountingCustomerView.Controllers return Redirect("~/Home/Enter"); } ViewBag.Lawyers = APIUser.GetRequest> - ($"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> - ($"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> - ($"api/contract/getmany?userId={APIUser.User.Id}"); + ($"api/contract/getallbyuser?userId={APIUser.User.Id}"); return View(); } diff --git a/CaseAccounting/CaseAccountingCustomerView/Views/Contracts/Create.cshtml b/CaseAccounting/CaseAccountingCustomerView/Views/Contracts/Create.cshtml index e281610..9443b03 100644 --- a/CaseAccounting/CaseAccountingCustomerView/Views/Contracts/Create.cshtml +++ b/CaseAccounting/CaseAccountingCustomerView/Views/Contracts/Create.cshtml @@ -21,4 +21,4 @@ Создать - \ No newline at end of file + \ No newline at end of file diff --git a/CaseAccounting/CaseAccountingCustomerView/Views/Contracts/Update.cshtml b/CaseAccounting/CaseAccountingCustomerView/Views/Contracts/Update.cshtml index e792c17..40b2675 100644 --- a/CaseAccounting/CaseAccountingCustomerView/Views/Contracts/Update.cshtml +++ b/CaseAccounting/CaseAccountingCustomerView/Views/Contracts/Update.cshtml @@ -31,4 +31,4 @@ } - \ No newline at end of file + \ No newline at end of file diff --git a/CaseAccounting/CaseAccountingCustomerView/Views/Home/Contracts.cshtml b/CaseAccounting/CaseAccountingCustomerView/Views/Home/Contracts.cshtml new file mode 100644 index 0000000..66dd2fc --- /dev/null +++ b/CaseAccounting/CaseAccountingCustomerView/Views/Home/Contracts.cshtml @@ -0,0 +1,72 @@ +@using CaseAccountingContracts.ViewModels + +@{ + ViewData["Title"] = "Контракты"; +} +
+

Контракты

+
+ + +
+ @{ + if (ViewBag.Contracts == null) + { +

Войдите в аккаунт

+ return; + } +
+ Добавить контракт +
+ + + + + + + + + + + + + @foreach (var item in ViewBag.Contracts) + { + + + + + + + + } + +
+ Услуга + + Цена + + Дата + + Изменить запись + + Удалить запись +
+ @item.Service + + @item.Coast + + @item.Date + + Изменить + + Удалить +
+ } +
+ + \ No newline at end of file diff --git a/CaseAccounting/CaseAccountingCustomerView/Views/Home/Lawyers.cshtml b/CaseAccounting/CaseAccountingCustomerView/Views/Home/Lawyers.cshtml index 4d6f0fe..031ea96 100644 --- a/CaseAccounting/CaseAccountingCustomerView/Views/Home/Lawyers.cshtml +++ b/CaseAccounting/CaseAccountingCustomerView/Views/Home/Lawyers.cshtml @@ -18,15 +18,6 @@
Добавить юриста
-
-
- - / @ViewBag.NumberOfPages -
- - Перейти - -
diff --git a/CaseAccounting/CaseAccountingCustomerView/Views/Home/Specializations.cshtml b/CaseAccounting/CaseAccountingCustomerView/Views/Home/Specializations.cshtml new file mode 100644 index 0000000..4be00f1 --- /dev/null +++ b/CaseAccounting/CaseAccountingCustomerView/Views/Home/Specializations.cshtml @@ -0,0 +1,60 @@ +@using CaseAccountingContracts.ViewModels + +@{ + ViewData["Title"] = "Специализации"; +} +
+

Специализации

+
+ + +
+ @{ + if (ViewBag.Specializations == null) + { +

Войдите в аккаунт

+ return; + } +
+ Добавить специализацию +
+ +
+ + + + + + + + + @foreach (var item in ViewBag.Specializations) + { + + + + + + } + +
+ Название + + Изменить запись + + Удалить запись +
+ @item.Name + + Изменить + + Удалить +
+ } + + + \ No newline at end of file diff --git a/CaseAccounting/CaseAccountingCustomerView/Views/Shared/_Layout.cshtml b/CaseAccounting/CaseAccountingCustomerView/Views/Shared/_Layout.cshtml index 93eaa25..97b2084 100644 --- a/CaseAccounting/CaseAccountingCustomerView/Views/Shared/_Layout.cshtml +++ b/CaseAccounting/CaseAccountingCustomerView/Views/Shared/_Layout.cshtml @@ -20,10 +20,19 @@ diff --git a/CaseAccounting/CaseAccountingCustomerView/Views/Specializations/AddLawyer.cshtml b/CaseAccounting/CaseAccountingCustomerView/Views/Specializations/AddLawyer.cshtml index b8f5bae..7b45bed 100644 --- a/CaseAccounting/CaseAccountingCustomerView/Views/Specializations/AddLawyer.cshtml +++ b/CaseAccounting/CaseAccountingCustomerView/Views/Specializations/AddLawyer.cshtml @@ -54,4 +54,4 @@ } - \ No newline at end of file + \ No newline at end of file diff --git a/CaseAccounting/CaseAccountingCustomerView/Views/Specializations/Create.cshtml b/CaseAccounting/CaseAccountingCustomerView/Views/Specializations/Create.cshtml index 173bc96..03034d9 100644 --- a/CaseAccounting/CaseAccountingCustomerView/Views/Specializations/Create.cshtml +++ b/CaseAccounting/CaseAccountingCustomerView/Views/Specializations/Create.cshtml @@ -17,4 +17,4 @@ Создать - \ No newline at end of file + \ No newline at end of file diff --git a/CaseAccounting/CaseAccountingCustomerView/Views/Specializations/Update.cshtml b/CaseAccounting/CaseAccountingCustomerView/Views/Specializations/Update.cshtml index 7bd97b1..28dc803 100644 --- a/CaseAccounting/CaseAccountingCustomerView/Views/Specializations/Update.cshtml +++ b/CaseAccounting/CaseAccountingCustomerView/Views/Specializations/Update.cshtml @@ -27,4 +27,4 @@ } - \ No newline at end of file + \ No newline at end of file diff --git a/CaseAccounting/CaseAccountingCustomerView/appsettings.json b/CaseAccounting/CaseAccountingCustomerView/appsettings.json index 9f3c15f..305cffc 100644 --- a/CaseAccounting/CaseAccountingCustomerView/appsettings.json +++ b/CaseAccounting/CaseAccountingCustomerView/appsettings.json @@ -7,5 +7,5 @@ }, "AllowedHosts": "*", - "IPAddress": "http://localhost:5146/" + "IPAddress": "http://localhost:5146" } diff --git a/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Contracts/contract-create.js b/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Contracts/contract-create.js index e41c91d..683a461 100644 --- a/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Contracts/contract-create.js +++ b/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Contracts/contract-create.js @@ -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) diff --git a/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Specializations/specialization-create.js b/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Specializations/specialization-create.js index b4fa649..8b087ad 100644 --- a/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Specializations/specialization-create.js +++ b/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Specializations/specialization-create.js @@ -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"; }); diff --git a/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Specializations/specialization-update.js b/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Specializations/specialization-update.js index af9b405..59d230d 100644 --- a/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Specializations/specialization-update.js +++ b/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Specializations/specialization-update.js @@ -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) diff --git a/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Specializations/specializations-add-lawyer.js b/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Specializations/specializations-add-lawyer.js index d3f1d63..5db763e 100644 --- a/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Specializations/specializations-add-lawyer.js +++ b/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Specializations/specializations-add-lawyer.js @@ -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) diff --git a/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Specializations/specializations.js b/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Specializations/specializations.js index 719a6ca..ac7e4ba 100644 --- a/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Specializations/specializations.js +++ b/CaseAccounting/CaseAccountingCustomerView/wwwroot/js/Specializations/specializations.js @@ -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(() => { diff --git a/CaseAccounting/CaseAccountingDataBaseImplement/CaseAccountingDatabase.cs b/CaseAccounting/CaseAccountingDataBaseImplement/CaseAccountingDatabase.cs index 75477ba..55243a9 100644 --- a/CaseAccounting/CaseAccountingDataBaseImplement/CaseAccountingDatabase.cs +++ b/CaseAccounting/CaseAccountingDataBaseImplement/CaseAccountingDatabase.cs @@ -18,8 +18,8 @@ namespace CaseAccountingDataBaseImplement Host=localhost; Port=5432; Database=CaseAccountingDatabase; - Username=courseuser; - Password=courseuser"); + Username=postgres; + Password=postgres"); } base.OnConfiguring(optionsBuilder); } diff --git a/CaseAccounting/CaseAccountingDataBaseImplement/Implements/ContractStorage.cs b/CaseAccounting/CaseAccountingDataBaseImplement/Implements/ContractStorage.cs index cc4cb1b..02c9179 100644 --- a/CaseAccounting/CaseAccountingDataBaseImplement/Implements/ContractStorage.cs +++ b/CaseAccounting/CaseAccountingDataBaseImplement/Implements/ContractStorage.cs @@ -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 diff --git a/CaseAccounting/CaseAccountingDataBaseImplement/Implements/LawyerStorage.cs b/CaseAccounting/CaseAccountingDataBaseImplement/Implements/LawyerStorage.cs index 754b078..6d499fe 100644 --- a/CaseAccounting/CaseAccountingDataBaseImplement/Implements/LawyerStorage.cs +++ b/CaseAccounting/CaseAccountingDataBaseImplement/Implements/LawyerStorage.cs @@ -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(); diff --git a/CaseAccounting/CaseAccountingDataBaseImplement/Implements/SpecializationStorage.cs b/CaseAccounting/CaseAccountingDataBaseImplement/Implements/SpecializationStorage.cs index e441ea7..911844d 100644 --- a/CaseAccounting/CaseAccountingDataBaseImplement/Implements/SpecializationStorage.cs +++ b/CaseAccounting/CaseAccountingDataBaseImplement/Implements/SpecializationStorage.cs @@ -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 diff --git a/CaseAccounting/CaseAccountingDataBaseImplement/Models/Contract.cs b/CaseAccounting/CaseAccountingDataBaseImplement/Models/Contract.cs index 3694646..14730de 100644 --- a/CaseAccounting/CaseAccountingDataBaseImplement/Models/Contract.cs +++ b/CaseAccounting/CaseAccountingDataBaseImplement/Models/Contract.cs @@ -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") }; } diff --git a/CaseAccounting/CaseAccountingDataBaseImplement/Models/Lawyer.cs b/CaseAccounting/CaseAccountingDataBaseImplement/Models/Lawyer.cs index 6f3f0d0..820d1d0 100644 --- a/CaseAccounting/CaseAccountingDataBaseImplement/Models/Lawyer.cs +++ b/CaseAccounting/CaseAccountingDataBaseImplement/Models/Lawyer.cs @@ -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") }; } diff --git a/CaseAccounting/CaseAccountingDataBaseImplement/Models/Specialization.cs b/CaseAccounting/CaseAccountingDataBaseImplement/Models/Specialization.cs index 31f373b..5829f94 100644 --- a/CaseAccounting/CaseAccountingDataBaseImplement/Models/Specialization.cs +++ b/CaseAccounting/CaseAccountingDataBaseImplement/Models/Specialization.cs @@ -30,7 +30,7 @@ namespace CaseAccountingDataBaseImplement.Models [ForeignKey("SpecializationId")] public virtual List 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"), }; }