diff --git a/VetClinic/VetClinic.sln b/VetClinic/VetClinic.sln index 14ba85c..7c5dd4e 100644 --- a/VetClinic/VetClinic.sln +++ b/VetClinic/VetClinic.sln @@ -11,12 +11,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VetClinicRestApi", "VetClin EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VetClinicContracts", "VetClinicContracts\VetClinicContracts.csproj", "{F2944E52-DC59-42B0-98D2-AC93E22DAB8C}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VetClinicAdminApp", "VetClinicAdminApi\VetClinicAdminApp.csproj", "{75280728-CC4C-4C43-8921-2DC4AD8A9192}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VetClinicDataBaseImplement", "VetClinicDataBaseImplement\VetClinicDataBaseImplement.csproj", "{55D8A594-2412-49E5-B306-F7D0385A870D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PharmacistApp", "PharmacistApp\PharmacistApp.csproj", "{EF0A9AB0-6C45-4FC7-9A6E-91C064477CD5}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VetClinicAdminApp", "VetClinicAdminApp\VetClinicAdminApp.csproj", "{762FE6A3-9A10-4542-B8D4-EC84456AF93A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -39,10 +39,6 @@ Global {F2944E52-DC59-42B0-98D2-AC93E22DAB8C}.Debug|Any CPU.Build.0 = Debug|Any CPU {F2944E52-DC59-42B0-98D2-AC93E22DAB8C}.Release|Any CPU.ActiveCfg = Release|Any CPU {F2944E52-DC59-42B0-98D2-AC93E22DAB8C}.Release|Any CPU.Build.0 = Release|Any CPU - {75280728-CC4C-4C43-8921-2DC4AD8A9192}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {75280728-CC4C-4C43-8921-2DC4AD8A9192}.Debug|Any CPU.Build.0 = Debug|Any CPU - {75280728-CC4C-4C43-8921-2DC4AD8A9192}.Release|Any CPU.ActiveCfg = Release|Any CPU - {75280728-CC4C-4C43-8921-2DC4AD8A9192}.Release|Any CPU.Build.0 = Release|Any CPU {55D8A594-2412-49E5-B306-F7D0385A870D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {55D8A594-2412-49E5-B306-F7D0385A870D}.Debug|Any CPU.Build.0 = Debug|Any CPU {55D8A594-2412-49E5-B306-F7D0385A870D}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -51,6 +47,10 @@ Global {EF0A9AB0-6C45-4FC7-9A6E-91C064477CD5}.Debug|Any CPU.Build.0 = Debug|Any CPU {EF0A9AB0-6C45-4FC7-9A6E-91C064477CD5}.Release|Any CPU.ActiveCfg = Release|Any CPU {EF0A9AB0-6C45-4FC7-9A6E-91C064477CD5}.Release|Any CPU.Build.0 = Release|Any CPU + {762FE6A3-9A10-4542-B8D4-EC84456AF93A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {762FE6A3-9A10-4542-B8D4-EC84456AF93A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {762FE6A3-9A10-4542-B8D4-EC84456AF93A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {762FE6A3-9A10-4542-B8D4-EC84456AF93A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/VetClinic/VetClinicAdminApp/Controllers/HomeController.cs b/VetClinic/VetClinicAdminApp/Controllers/HomeController.cs index e8bf336..55e19d7 100644 --- a/VetClinic/VetClinicAdminApp/Controllers/HomeController.cs +++ b/VetClinic/VetClinicAdminApp/Controllers/HomeController.cs @@ -157,7 +157,6 @@ View(APIAdmin.GetRequest>($"api/vaccination/getvaccin { return Redirect("~/Home/Enter"); } - ViewBag.Services = APIAdmin.GetRequest>($"api/service/getservices?adminid={APIAdmin.Admin.Id}"); return View(); } public IActionResult CreateVaccination() @@ -167,7 +166,7 @@ View(APIAdmin.GetRequest>($"api/vaccination/getvaccin } [HttpPost] - public void Create(string name, DateTime visitdate) + public void Create(string name, DateTime date) { if (APIAdmin.Admin == null) { @@ -180,7 +179,7 @@ View(APIAdmin.GetRequest>($"api/vaccination/getvaccin APIAdmin.PostRequest("api/visit/createvisit", new VisitBindingModel { NameVisit = name, - DateVisit = visitdate, + DateVisit = date, AdminId = APIAdmin.Admin.Id }); Response.Redirect("Index"); @@ -205,7 +204,7 @@ View(APIAdmin.GetRequest>($"api/vaccination/getvaccin Response.Redirect("IndexAnimals"); } [HttpPost] - public void CreateVaccination(int animale, string name, string cost,DateTime date) + public void CreateVaccination(int animal, string name, string cost,DateTime date) { if (APIAdmin.Admin == null) { @@ -241,8 +240,8 @@ View(APIAdmin.GetRequest>($"api/vaccination/getvaccin } APIAdmin.PostRequest("api/vaccination/createvaccination", new VaccinationBindingModel { + AnimalId = animal, NameVaccination = name, - AnimalId = animale, CostVaccination = Math.Round(_cost, 2), DateStamp = date }); @@ -325,13 +324,13 @@ View(APIAdmin.GetRequest>($"api/vaccination/getvaccin { return Redirect("~/Home/Enter"); } - ViewBag.Visits = APIAdmin.GetRequest>($"api/visit/getvisits?pharmacistid={APIAdmin.Admin.Id}"); + ViewBag.Visits = APIAdmin.GetRequest>($"api/visit/getvisits?adminid={APIAdmin.Admin.Id}"); ViewBag.Services = APIAdmin.GetRequest>($"api/service/getservices"); return View(); } [HttpPost] - public void Update(int visit, string name, DateTime vistdate) + public void Update(int visit, string name, DateTime date) { if (APIAdmin.Admin == null) { @@ -345,7 +344,8 @@ View(APIAdmin.GetRequest>($"api/vaccination/getvaccin { Id = visit, NameVisit = name, - DateVisit = vistdate, + AdminId = APIAdmin.Admin.Id, + DateVisit = date, }); Response.Redirect("Index"); } @@ -457,6 +457,17 @@ View(APIAdmin.GetRequest>($"api/vaccination/getvaccin }); Response.Redirect("Index"); } + public IActionResult Vaccinations() + { + if (APIAdmin.Admin == null) + { + return Redirect("~/Home/Enter"); + } + var res = APIAdmin.GetRequest>($"api/vaccination/getvaccinations?pharmacistid={APIAdmin.Admin.Id}"); + return +View(res); + + } public IActionResult UpdateVaccination() { if (APIAdmin.Admin == null) @@ -469,27 +480,42 @@ View(APIAdmin.GetRequest>($"api/vaccination/getvaccin } [HttpPost] - public void UpdateVaccination(int animale,int vaccination, string name, double cost, DateTime date) + public void UpdateVaccination(int vaccination,int animal, string name, string cost, DateTime date) { if (APIAdmin.Admin == null) { throw new Exception("Вы как сюда попали? Сюда вход только авторизованным"); } - if (string.IsNullOrEmpty(name)) + StringBuilder st = new StringBuilder(cost); + for (int i = 0; i < cost.Length; i++) + { + if (cost[i] == '.') + st[i] = ','; + } + cost = st.ToString(); + double _cost; + try + { + _cost = Convert.ToDouble(cost); + } + catch (Exception ex) + { + throw new Exception("Îøèáêà â ââåäåííûõ äàííûõ"); + } + if (string.IsNullOrEmpty(name) || _cost <= 0) { throw new Exception("Ошибка в введенных данных"); } APIAdmin.PostRequest("api/vaccination/updatevaccination", new VaccinationBindingModel { - Id = vaccination, - AnimalId = animale, + AnimalId = animal, NameVaccination = name, - CostVaccination = cost, + CostVaccination = Math.Round(_cost, 2), DateStamp = date }); - Response.Redirect("IndexVaccination"); + Response.Redirect("IndexVaccinations"); } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() @@ -540,6 +566,21 @@ View(APIAdmin.GetRequest>($"api/vaccination/getvaccin return default; } + return result; + } + [HttpGet] + public VaccinationViewModel GetVaccination(int adminId) + { + if (APIAdmin.Admin == null) + { + throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì"); + } + var result = APIAdmin.GetRequest($"api/vaccination/getvaccination?adminid={adminId}"); + if (result == null) + { + return default; + } + return result; } } diff --git a/VetClinic/VetClinicAdminApp/Views/Home/Create.cshtml b/VetClinic/VetClinicAdminApp/Views/Home/Create.cshtml index 2f2a5b5..c08b943 100644 --- a/VetClinic/VetClinicAdminApp/Views/Home/Create.cshtml +++ b/VetClinic/VetClinicAdminApp/Views/Home/Create.cshtml @@ -16,7 +16,7 @@
Дата:
- +
@@ -36,6 +36,5 @@
- diff --git a/VetClinic/VetClinicAdminApp/Views/Home/CreateVaccination.cshtml b/VetClinic/VetClinicAdminApp/Views/Home/CreateVaccination.cshtml index 606da21..8fd6ab5 100644 --- a/VetClinic/VetClinicAdminApp/Views/Home/CreateVaccination.cshtml +++ b/VetClinic/VetClinicAdminApp/Views/Home/CreateVaccination.cshtml @@ -27,7 +27,7 @@
Дата:
- +
@@ -36,23 +36,6 @@
- - + diff --git a/VetClinic/VetClinicAdminApp/Views/Home/IndexVaccinations.cshtml b/VetClinic/VetClinicAdminApp/Views/Home/IndexVaccinations.cshtml index 6d09a4e..156e507 100644 --- a/VetClinic/VetClinicAdminApp/Views/Home/IndexVaccinations.cshtml +++ b/VetClinic/VetClinicAdminApp/Views/Home/IndexVaccinations.cshtml @@ -33,6 +33,9 @@ Название + + Стоимость + Дата diff --git a/VetClinic/VetClinicAdminApp/Views/Home/Update.cshtml b/VetClinic/VetClinicAdminApp/Views/Home/Update.cshtml index f8241c6..a97c5bb 100644 --- a/VetClinic/VetClinicAdminApp/Views/Home/Update.cshtml +++ b/VetClinic/VetClinicAdminApp/Views/Home/Update.cshtml @@ -22,16 +22,16 @@
Дата:
- +
Услуги:
@@ -48,14 +48,16 @@