Compare commits

...

2 Commits

15 changed files with 211 additions and 88 deletions

View File

@ -6,6 +6,7 @@ using VetClinicContracts.ViewModels;
using VetClinicDataModels.Models;
using System.Text;
using VetClinicContracts.SearchModels;
using System.IO.Pipelines;
namespace VetClinicAdminApp.Controllers
@ -18,7 +19,17 @@ namespace VetClinicAdminApp.Controllers
{
_logger = logger;
}
[HttpGet]
public IActionResult ServiceListReport()
{
ViewBag.Animals = APIAdmin.GetRequest<List<AnimalViewModel>>($"api/animal/getanimallist?adminid={APIAdmin.Admin.Id}");
return View();
}
[HttpGet]
public IActionResult Report()
{
return View();
}
public IActionResult Index()
{
if (APIAdmin.Admin == null)
@ -46,7 +57,7 @@ View(APIAdmin.GetRequest<List<AnimalViewModel>>($"api/animal/getanimallist?admin
return Redirect("~/Home/Enter");
}
return
View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccinations?vaccinationId={APIAdmin.Admin.Id}"));
View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccinations?adminId={APIAdmin.Admin.Id}"));
}
@ -137,6 +148,7 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
{
return Redirect("~/Home/Enter");
}
ViewBag.Services = APIAdmin.GetRequest<List<ServiceViewModel>>($"api/service/getservices");
return View();
}
public IActionResult CreateAnimal()
@ -145,11 +157,12 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
{
return Redirect("~/Home/Enter");
}
ViewBag.Services = APIAdmin.GetRequest<List<ServiceViewModel>>($"api/service/getservices?adminid={APIAdmin.Admin.Id}");
return View();
}
public IActionResult CreateVaccination()
{
ViewBag.Animals = APIAdmin.GetRequest<List<AnimalViewModel>>("api/animal/getanimallist");
ViewBag.Animals = APIAdmin.GetRequest<List<AnimalViewModel>>($"api/animal/getanimallist?adminid={APIAdmin.Admin.Id}");
return View();
}
@ -192,7 +205,7 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
Response.Redirect("IndexAnimals");
}
[HttpPost]
public void CreateVaccination(int animale, string name, double cost,DateTime date)
public void CreateVaccination(int animale, string name, string cost,DateTime date)
{
if (APIAdmin.Admin == null)
{
@ -202,15 +215,35 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
{
throw new Exception("Ошибка в введенных данных");
}
if (cost <= 0)
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 (_cost <= 0)
{
throw new Exception("Цена должна быть выше 0");
}
if (date == null)
{
throw new Exception("Выберите дату");
}
APIAdmin.PostRequest("api/vaccination/createvaccination", new VaccinationBindingModel
{
NameVaccination = name,
AnimalId = animale,
CostVaccination = cost,
CostVaccination = Math.Round(_cost, 2),
DateStamp = date
});
Response.Redirect("IndexVaccinations");
@ -292,7 +325,8 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
{
return Redirect("~/Home/Enter");
}
ViewBag.Visits = APIAdmin.GetRequest<List<VisitViewModel>>("api/visit/getvisits");
ViewBag.Visits = APIAdmin.GetRequest<List<VisitViewModel>>($"api/visit/getvisits?pharmacistid={APIAdmin.Admin.Id}");
ViewBag.Services = APIAdmin.GetRequest<List<ServiceViewModel>>($"api/service/getservices");
return View();
}
@ -322,6 +356,7 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
return Redirect("~/Home/Enter");
}
ViewBag.Animals = APIAdmin.GetRequest<List<AnimalViewModel>>($"api/animal/getanimallist?adminid={APIAdmin.Admin.Id}");
return View();
}
@ -429,6 +464,7 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccin
return Redirect("~/Home/Enter");
}
ViewBag.Vaccinations = APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccinations?adminid={APIAdmin.Admin.Id}");
ViewBag.Animals = APIAdmin.GetRequest<List<AnimalViewModel>>($"api/animal/getanimallist?adminid={APIAdmin.Admin.Id}");
return View();
}

View File

@ -16,7 +16,18 @@
<div class="row">
<div class="col-4">Дата:</div>
<div class="col-8">
<input type="datetime" id="datetime" name="date" />
<input type="date" id="date" name="date" />
</div>
</div>
<div class="row">
<div class="col-4">Услуги:</div>
<div class="col-8">
<select name="services" class="form-control" multiple size="6" id="services">
@foreach (var service in ViewBag.Services)
{
<option value="@service.Id">@service.ServiceName</option>
}
</select>
</div>
</div>
<div class="row">

View File

@ -20,7 +20,6 @@
<p>
<a asp-action="Update">Редактировать визит</a>
<a asp-action="Delete">Удалить визит</a>
<a asp-action="ServiceVisits">Связать визит и услуги</a>
</p>
<p>
<a asp-action="Create">Создать визит</a>

View File

@ -0,0 +1,59 @@
@{
ViewData["Title"] = "Report";
}
<div class="text-center">
<h1 class="display-4">Список визитов с расшифровкой по медикаментам и прививкам</h1>
</div>
<div class="text-center">
@{
// if (Model == null)
// {
// <h3 class="display-4">Авторизируйтесь!</h3>
// return;
// }
<div class="row mb-5">
<div class="col-4">Начальная дата:</div>
<div class="col-8">
<input type="date" id="startDate" name="startDate" class="form-control">
</div>
</div>
<div class="row mb-5">
<div class="col-4">Конечная дата:</div>
<div class="col-8">
<input type="date" id="endDate" name="endDate" class="form-control">
</div>
</div>
<table class="table">
<thead>
<tr>
<th>
Номер
</th>
<th>
Дата
</th>
<th>
Визит
</th>
<th>
Медикамент
</th>
<th>
Прививка
</th>
</tr>
</thead>
<tbody>
будет заполняться вьюшками отчета
</tbody>
</table>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Создать отчет" class="btn btn-primary" /></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Отправить на почту" class="btn btn-primary" /></div>
</div>
}
</div>

View File

@ -0,0 +1,30 @@
@using VetClinicContracts.ViewModels;
@{
ViewData["Title"] = "ServiceListReport";
}
<div class="text-center">
<h2 class="display-4">Создать списки услуг для животных</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Животные:</div>
<div class="col-8">
<select name="animals" class="form-control" multiple size="5" id="animals">
@foreach (var animal in ViewBag.Animals)
{
<option value="@animal.Id">@animal.AnimalName</option>
}
</select>
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Word" class="btn btn-primary" /></div>
<div class="col-4"><input type="submit" value="Excel" class="btn btn-primary" /></div>
</div>
</form>

View File

@ -1,65 +0,0 @@
@using VetClinicContracts.ViewModels;
@{
ViewData["Title"] = "ServiceVisits";
}
<div class="text-center">
<h2 class="display-4">Связывание визита и услуги</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Визит:</div>
<div class="col-8">
<select id="visit" name="visit" class="form-control" asp-items="@(new SelectList(@ViewBag.Visits, "Id", "NameVisit"))"></select>
</div>
</div>
<input style = "visibility: hidden" type="text" name="name" id="name" class="form-control" />
<input style="visibility: hidden" type="datetime" id="datetime" name="date" class="form-control" />
<div class="row">
<div class="col-4">Услуги:</div>
<div class="col-8">
<select name="services" class="form-control" multiple size="5" id="services">
@foreach (var service in ViewBag.Services)
{
<option value="@service.Id" id="@service.ServicesName">@service.ServicesName</option>
}
</select>
</div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
</div>
</form>
@section Scripts
{
<script>
function check() {
var animal = $('#visit').val();
$("#services option:selected").removeAttr("selected");
if (animal) {
$.ajax({
method: "GET",
url: "/Home/GetVisit",
data: { animalId: animal },
success: function (result) {
console.log(result.item2);
$('#name').val(result.item1.visitName);
$('#date').val(result.item1.date);
$.map(result.item2, function (n) {
console.log("#" + n);
$("#" + n).attr("selected", "selected")
});
}
});
};
}
check();
$('#visit').on('change', function () {
check();
});
</script>
}

View File

@ -22,10 +22,20 @@
<div class="row">
<div class="col-4">Дата:</div>
<div class="col-8">
<input type="datetime" id="datetime" name="date" />
<input type="date" id="date" name="date" />
</div>
</div>
<div class="row">
<div class="col-4">Услуги:</div>
<div class="col-8">
<select name="services" class="form-control" multiple size="5" id="services">
@foreach (var services in ViewBag.Services)
{
<option value="@services.Id" data-name="@services.ServiceName">@services.ServiceName</option>
}
</select>
</div>
</div>
<div class="row">
<div class="col-8"></div>
@ -46,6 +56,10 @@
success: function (result) {
$('#name').val(result.item1.vistName);
$('#date').val(result.item1.date);
$.map(result.item2, function (n) {
console.log("#" + n);
$(`option[data-name=${n}]`).attr("selected", "selected")
});
}
});
};

View File

@ -43,7 +43,7 @@
data: { animalId: animal },
success: function (result) {
$('#name').val(result.item1.animalName);
$('#family').val(result.item1.price);
$('#family').val(result.item1.family);
}
});
};

View File

@ -12,6 +12,17 @@
<select id="vaccination" name="vaccination" class="form-control" asp-items="@(new SelectList(@ViewBag.Vaccinations, "Id", "NameVaccination"))"></select>
</div>
</div>
<div class="row">
<div class="col-4">Животное:</div>
<div class="col-8">
<select name="animal" class="form-control" id="animal">
@foreach (var animal in ViewBag.Animals)
{
<option value="@animal.Id" id="@animal.Id">@animal.AnimalName</option>
}
</select>
</div>
</div>
<div class="row">
<div class="col-4">Название:</div>
<div class="col-8">
@ -44,13 +55,20 @@
if (snack) {
$.ajax({
method: "POST",
url: "/Home/GetAnimal",
data: { animal: animal },
url: "/Home/GetVaccination",
data: { vaccinationId: vaccinationId },
success: function (result) {
$("#animal").val(result);
$('#name').val(result.text);
$('#cost').val(result.text);
$('#date').val(result.date);
$(`option[data-name=${result.animalId}]`).attr("selected", "selected")
}
});
};
}
check();
$('#vaccination').on('change', function () {
check();
});
</script>

View File

@ -22,7 +22,7 @@
<select name="visits" class="form-control" multiple size="5" id="visits">
@foreach (var visit in ViewBag.Visits)
{
<option value="@visit.Id" id="@visit.NameVisit">@visit.NameVisit</option>
<option value="@visit.Id" data-name="@visit.NameVisit">@visit.NameVisit</option>
}
</select>
</div>

View File

@ -32,6 +32,12 @@
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="ServiceListReport">Выгрузка списка</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Report">Отчет</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Enter">Вход</a>
</li>

View File

@ -9,6 +9,7 @@ namespace VetClinicContracts.SearchModels
public class VaccinationSearchModel
{
public int? Id { get; set; }
public int? AdminId { get; set; }
public string? NameVaccination { get; set; }
public double? CostVaccination { get; set; }

View File

@ -25,7 +25,7 @@ namespace VetClinicDataBaseImplement.Implements
using var context = new VetClinicDatabase();
return context.Vaccinations.Include(x => x.Animal).Where(x => (!model.Id.HasValue || model.Id == x.Id)
&& (!model.AnimalId.HasValue || model.AnimalId == x.AnimalId) && (!model.DateFrom.HasValue || model.DateFrom <= x.DateStamp)
&& (!model.DateTo.HasValue || model.DateTo >= x.DateStamp))
&& (!model.DateTo.HasValue || model.DateTo >= x.DateStamp) && (!model.AdminId.HasValue || model.AdminId == x.Animal.AdminId))
.Select(x => x.GetViewModel)
.ToList();
}

View File

@ -11,7 +11,7 @@ namespace VetClinicDataBaseImplement
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=VetClinicDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS02;Initial Catalog=VetClinicDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
}
base.OnConfiguring(optionsBuilder);
}

View File

@ -21,22 +21,36 @@ namespace VetClinicRestApi.Controllers
_logger = logger;
_vaccination = vaccination;
}
[HttpGet]
public List<VaccinationViewModel>? GetVaccinations(int? animalId)
public VaccinationViewModel GetVaccination(int vaccinationId)
{
try
{
if (!animalId.HasValue)
var elem = _vaccination.ReadElement(new VaccinationSearchModel { Id = vaccinationId });
return elem;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения прививки по id={Id}", vaccinationId);
throw;
}
}
[HttpGet]
public List<VaccinationViewModel>? GetVaccinations(int? adminld)
{
try
{
if (!adminld.HasValue)
return _vaccination.ReadList(null);
return _vaccination.ReadList(new VaccinationSearchModel
{
AnimalId = animalId
AdminId = adminld
});
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения списка привиовк животного id ={ Id}", animalId);
_logger.LogError(ex, "Ошибка получения списка прививок пользователя id ={ Id}", adminld);
throw;
}
}