diff --git a/VetClinic/VetClinicAdminApi/Controllers/HomeController.cs b/VetClinic/VetClinicAdminApi/Controllers/HomeController.cs index aff98fe..6dbefc5 100644 --- a/VetClinic/VetClinicAdminApi/Controllers/HomeController.cs +++ b/VetClinic/VetClinicAdminApi/Controllers/HomeController.cs @@ -3,6 +3,7 @@ using VetClinicAdminApp.Models; using System.Diagnostics; using VetClinicContracts.BindingModels; using VetClinicContracts.ViewModels; +using VetClinicDataModels.Models; namespace VetClinicAdminApp.Controllers @@ -25,6 +26,26 @@ namespace VetClinicAdminApp.Controllers return View(APIAdmin.GetRequest>($"api/visit/getvisits?vistId={APIAdmin.Admin.Id}")); + } + public IActionResult IndexAnimals() + { + if (APIAdmin.Admin == null) + { + return Redirect("~/Home/Enter"); + } + return +View(APIAdmin.GetRequest>($"api/animal/getanimallist?animalId={APIAdmin.Admin.Id}")); + + } + public IActionResult IndexVaccinations() + { + if (APIAdmin.Admin == null) + { + return Redirect("~/Home/Enter"); + } + return +View(APIAdmin.GetRequest>($"api/vaccination/getvaccinations?vaccinationId={APIAdmin.Admin.Id}")); + } [HttpGet] @@ -116,11 +137,22 @@ View(APIAdmin.GetRequest>($"api/visit/getvisits?vistId={API } return View(); } - - + public IActionResult CreateAnimal() + { + if (APIAdmin.Admin == null) + { + return Redirect("~/Home/Enter"); + } + return View(); + } + public IActionResult CreateVaccination() + { + ViewBag.Animals = APIAdmin.GetRequest>("api/animal/getanimallist"); + return View(); + } [HttpPost] - public void CreateVisit(string name, DateTime visitdate) + public void Create(string name, DateTime visitdate) { if (APIAdmin.Admin == null) { @@ -138,8 +170,51 @@ View(APIAdmin.GetRequest>($"api/visit/getvisits?vistId={API }); Response.Redirect("Index"); } - - public IActionResult DeleteMedicine() + [HttpPost] + public void CreateAnimal(string animalname,string family) + { + if (APIAdmin.Admin == null) + { + throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì"); + } + if (string.IsNullOrEmpty(animalname)) + { + throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ"); + } + APIAdmin.PostRequest("api/animal/createanimal", new AnimalBindingModel + { + AnimalName = animalname, + Family = family, + AdminId = APIAdmin.Admin.Id + }); + Response.Redirect("IndexAnimals"); + } + [HttpPost] + public void CreateVaccination(int animale, string name, double cost,DateTime date) + { + if (APIAdmin.Admin == null) + { + throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì"); + } + if (string.IsNullOrEmpty(name)) + { + throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ"); + } + if (cost <= 0) + { + throw new Exception("Цена должна быть выше 0"); + } + APIAdmin.PostRequest("api/vaccination/createvaccination", new VaccinationBindingModel + { + NameVaccination = name, + AnimalId = animale, + CostVaccination = cost, + DateStamp = date + }); + Response.Redirect("IndexVaccinations"); + } + + public IActionResult Delete() { if (APIAdmin.Admin == null) { @@ -150,7 +225,7 @@ View(APIAdmin.GetRequest>($"api/visit/getvisits?vistId={API } [HttpPost] - public void DeleteVisit(int shop) + public void DeleteVisit(int visit) { if (APIAdmin.Admin == null) { @@ -158,18 +233,64 @@ View(APIAdmin.GetRequest>($"api/visit/getvisits?vistId={API } APIAdmin.PostRequest("api/visit/deletevisit", new VisitBindingModel { - Id = shop + Id = visit }); Response.Redirect("Index"); } + public IActionResult DeleteAnimal() + { + if (APIAdmin.Admin == null) + { + return Redirect("~/Home/Enter"); + } + ViewBag.Animals = APIAdmin.GetRequest>($"api/animal/getanimallist?adminid={APIAdmin.Admin.Id}"); + return View(); + } + public IActionResult DeleteVaccination() + { + if (APIAdmin.Admin == null) + { + return Redirect("~/Home/Enter"); + } + ViewBag.Vaccinations = APIAdmin.GetRequest>($"api/vaccination/getvaccinations?adminid={APIAdmin.Admin.Id}"); + return View(); + } + + [HttpPost] + public void DeleteAnimal(int animal) + { + if (APIAdmin.Admin == null) + { + throw new Exception("Вы как сюда попали? Сюда вход только авторизованным"); + } + APIAdmin.PostRequest("api/animal/deleteanimal", new AnimalBindingModel + { + Id = animal + }); + Response.Redirect("IndexAnimals"); + } + [HttpPost] + public void DeleteVaccination(int vaccination) + { + if (APIAdmin.Admin == null) + { + throw new Exception("Вы как сюда попали? Сюда вход только авторизованным"); + } + APIAdmin.PostRequest("api/vaccination/deletevaccination", new VaccinationBindingModel + { + Id = vaccination + }); + Response.Redirect("IndexVaccinations"); + } + public IActionResult Update() { if (APIAdmin.Admin == null) { return Redirect("~/Home/Enter"); } - ViewBag.Medicines = APIAdmin.GetRequest>("api/shop/getvisits"); + ViewBag.Medicines = APIAdmin.GetRequest>("api/visit/getvisits"); return View(); } @@ -180,7 +301,7 @@ View(APIAdmin.GetRequest>($"api/visit/getvisits?vistId={API { throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì"); } - if (string.IsNullOrEmpty(name) ) + if (string.IsNullOrEmpty(name)) { throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ"); } @@ -192,7 +313,69 @@ View(APIAdmin.GetRequest>($"api/visit/getvisits?vistId={API }); Response.Redirect("Index"); } + public IActionResult UpdateAnimal() + { + if (APIAdmin.Admin == null) + { + return Redirect("~/Home/Enter"); + } + ViewBag.Animals = APIAdmin.GetRequest>($"api/animal/getanimallist?adminid={APIAdmin.Admin.Id}"); + return View(); + } + [HttpPost] + public void UpdateAnimal(int animal, string name, string family) + { + if (APIAdmin.Admin == null) + { + throw new Exception("Вы как сюда попали? Сюда вход только авторизованным"); + } + if (string.IsNullOrEmpty(name)) + { + throw new Exception("Ошибка в введенных данных"); + } + APIAdmin.PostRequest("api/animal/updateanimal", new AnimalBindingModel + { + Id = animal, + AnimalName = name, + Family = family + + }); + Response.Redirect("IndexAnimals"); + } + public IActionResult UpdateVaccination() + { + if (APIAdmin.Admin == null) + { + return Redirect("~/Home/Enter"); + } + ViewBag.Vaccinations = APIAdmin.GetRequest>($"api/vaccination/getvaccinations?adminid={APIAdmin.Admin.Id}"); + return View(); + } + + [HttpPost] + public void UpdateVaccination(int animale,int vaccination, string name, double cost, DateTime date) + { + if (APIAdmin.Admin == null) + { + throw new Exception("Вы как сюда попали? Сюда вход только авторизованным"); + } + if (string.IsNullOrEmpty(name)) + { + throw new Exception("Ошибка в введенных данных"); + } + APIAdmin.PostRequest("api/vaccination/updatevaccination", new VaccinationBindingModel + { + + Id = vaccination, + AnimalId = animale, + NameVaccination = name, + CostVaccination = cost, + DateStamp = date + + }); + Response.Redirect("IndexVaccination"); + } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() { @@ -200,7 +383,7 @@ View(APIAdmin.GetRequest>($"api/visit/getvisits?vistId={API } [HttpGet] - public Tuple? GetMedicine(int visitId) + public Tuple? GetVisit(int visitId) { if (APIAdmin.Admin == null) { diff --git a/VetClinic/VetClinicAdminApi/Views/Home/Create.cshtml b/VetClinic/VetClinicAdminApi/Views/Home/Create.cshtml index dbb5040..3c175db 100644 --- a/VetClinic/VetClinicAdminApi/Views/Home/Create.cshtml +++ b/VetClinic/VetClinicAdminApi/Views/Home/Create.cshtml @@ -6,12 +6,7 @@

Создание визита

-
-
Животное:
-
- -
-
+
Название:
@@ -21,7 +16,7 @@
Дата:
- +
diff --git a/VetClinic/VetClinicAdminApi/Views/Home/CreateAnimal.cshtml b/VetClinic/VetClinicAdminApi/Views/Home/CreateAnimal.cshtml new file mode 100644 index 0000000..70ca1c8 --- /dev/null +++ b/VetClinic/VetClinicAdminApi/Views/Home/CreateAnimal.cshtml @@ -0,0 +1,29 @@ +@{ + ViewData["Title"] = "CreateAnimal"; +} + +
+

Создание животного

+
+ +
+
Название:
+
+ +
+
+
+
Семейство:
+
+ +
+
+
+
+
+ +
+
+ + + diff --git a/VetClinic/VetClinicAdminApi/Views/Home/CreateVaccination.cshtml b/VetClinic/VetClinicAdminApi/Views/Home/CreateVaccination.cshtml new file mode 100644 index 0000000..606da21 --- /dev/null +++ b/VetClinic/VetClinicAdminApi/Views/Home/CreateVaccination.cshtml @@ -0,0 +1,58 @@ +@{ + ViewData["Title"] = "CreateVaccination"; +} + +
+

Создание прививки

+
+
+
+
Животное:
+
+ +
+
+
+
Название:
+
+ +
+
+
+
Цена:
+
+ +
+
+
+
Дата:
+
+ +
+
+
+
+
+ +
+
+ +
+ + diff --git a/VetClinic/VetClinicAdminApi/Views/Home/DeleteAnimal.cshtml b/VetClinic/VetClinicAdminApi/Views/Home/DeleteAnimal.cshtml new file mode 100644 index 0000000..19fc1c8 --- /dev/null +++ b/VetClinic/VetClinicAdminApi/Views/Home/DeleteAnimal.cshtml @@ -0,0 +1,18 @@ +@{ + ViewData["Title"] = "DeleteAnimal"; +} +
+

Удаление животного

+
+
+
+
Животное:
+
+ +
+
+
+
+
+
+
\ No newline at end of file diff --git a/VetClinic/VetClinicAdminApi/Views/Home/DeleteVaccination.cshtml b/VetClinic/VetClinicAdminApi/Views/Home/DeleteVaccination.cshtml new file mode 100644 index 0000000..71f9399 --- /dev/null +++ b/VetClinic/VetClinicAdminApi/Views/Home/DeleteVaccination.cshtml @@ -0,0 +1,37 @@ +@{ + ViewData["Title"] = "CreateVaccination"; +} + +
+

Удаление прививки

+
+
+
+
Прививка:
+
+ +
+
+
+
+
+
+
+ + diff --git a/VetClinic/VetClinicAdminApi/Views/Home/Index.cshtml b/VetClinic/VetClinicAdminApi/Views/Home/Index.cshtml index 078eb8e..bb9b3b7 100644 --- a/VetClinic/VetClinicAdminApi/Views/Home/Index.cshtml +++ b/VetClinic/VetClinicAdminApi/Views/Home/Index.cshtml @@ -27,9 +27,6 @@ Номер - - Животоное - Название @@ -46,9 +43,7 @@ @Html.DisplayFor(modelItem => item.Id) - - @Html.DisplayFor(modelItem => item.AnimalName) - + @Html.DisplayFor(modelItem => item.NameVisit) diff --git a/VetClinic/VetClinicAdminApi/Views/Home/IndexAnimals.cshtml b/VetClinic/VetClinicAdminApi/Views/Home/IndexAnimals.cshtml new file mode 100644 index 0000000..f3aad95 --- /dev/null +++ b/VetClinic/VetClinicAdminApi/Views/Home/IndexAnimals.cshtml @@ -0,0 +1,62 @@ +@using VetClinicContracts.ViewModels + +@model List + +@{ + ViewData["Title"] = "IndexAnimals"; +} + +
+

Животные

+
+ +
+ @{ + if (Model == null) + { +

Авторизируйтесь

+ return; + } +

+ Редактировать животное + Удалить животное +

+

+ Создать животное +

+ + + + + + + + + + + @foreach (var item in Model) + { + + + + + + + + } + +
+ Номер + + Название + + Семейство +
+ @Html.DisplayFor(modelItem => item.Id) + + @Html.DisplayFor(modelItem => item.AnimalName) + + @Html.DisplayFor(modelItem => item.Family) +
+ } +
\ No newline at end of file diff --git a/VetClinic/VetClinicAdminApi/Views/Home/IndexVaccinations.cshtml b/VetClinic/VetClinicAdminApi/Views/Home/IndexVaccinations.cshtml new file mode 100644 index 0000000..6d09a4e --- /dev/null +++ b/VetClinic/VetClinicAdminApi/Views/Home/IndexVaccinations.cshtml @@ -0,0 +1,64 @@ +@using VetClinicContracts.ViewModels + +@model List + +@{ + ViewData["Title"] = "IndexVaccinations"; +} + +
+

Прививки

+
+ +
+ @{ + if (Model == null) + { +

Авторизируйтесь

+ return; + } +

+ Изменить прививку + Удалить прививку +

+

+ Создать прививку +

+ + + + + + + + + + + @foreach (var item in Model) + { + + + + + + + + } + +
+ Номер + + Название + + Дата +
+ @Html.DisplayFor(modelItem => item.Id) + + @Html.DisplayFor(modelItem => item.NameVaccination) + + @Html.DisplayFor(modelItem => item.CostVaccination) + + @Html.DisplayFor(modelItem => item.DateStamp) +
+ } +
\ No newline at end of file diff --git a/VetClinic/VetClinicAdminApi/Views/Home/UpdateAnimal.cshtml b/VetClinic/VetClinicAdminApi/Views/Home/UpdateAnimal.cshtml new file mode 100644 index 0000000..30d5dc9 --- /dev/null +++ b/VetClinic/VetClinicAdminApi/Views/Home/UpdateAnimal.cshtml @@ -0,0 +1,56 @@ +@using VetClinicContracts.ViewModels; + +@{ + ViewData["Title"] = "UpdateAnimal"; +} + +
+

Редактирование животного

+
+
+
+
Животное:
+
+ +
+ +
+
+
Название:
+
+
+
+
Семейство:
+
+
+ + +
+
+
+
+
+ +@section Scripts +{ + +} \ No newline at end of file diff --git a/VetClinic/VetClinicAdminApi/Views/Home/UpdateVaccination.cshtml b/VetClinic/VetClinicAdminApi/Views/Home/UpdateVaccination.cshtml new file mode 100644 index 0000000..e0cc10a --- /dev/null +++ b/VetClinic/VetClinicAdminApi/Views/Home/UpdateVaccination.cshtml @@ -0,0 +1,56 @@ +@{ + ViewData["Title"] = "UpdateVaccination"; +} + +
+

Редактирование прививки

+
+
+
+
Прививка:
+
+ +
+
+
+
Название:
+
+ +
+
+
+
Цена:
+
+ +
+
+
+
Дата:
+
+ +
+
+
+
+
+
+ +
+ + diff --git a/VetClinic/VetClinicAdminApi/Views/Shared/_Layout.cshtml b/VetClinic/VetClinicAdminApi/Views/Shared/_Layout.cshtml index 6a922ea..2b2f0b6 100644 --- a/VetClinic/VetClinicAdminApi/Views/Shared/_Layout.cshtml +++ b/VetClinic/VetClinicAdminApi/Views/Shared/_Layout.cshtml @@ -3,7 +3,7 @@ - @ViewData["Title"] - IceCreamShopClientApp + @ViewData["Title"] - VetClinicAdminApp @@ -13,7 +13,7 @@