пилю интерфейс

This commit is contained in:
goblinrf 2024-05-25 00:45:55 +04:00
parent c6518591c9
commit 427b6f07b2
19 changed files with 116 additions and 85 deletions

View File

@ -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

View File

@ -157,7 +157,6 @@ 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()
@ -167,7 +166,7 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"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<List<VaccinationViewModel>>($"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<List<VaccinationViewModel>>($"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<List<VaccinationViewModel>>($"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<List<VaccinationViewModel>>($"api/vaccination/getvaccin
{
return Redirect("~/Home/Enter");
}
ViewBag.Visits = APIAdmin.GetRequest<List<VisitViewModel>>($"api/visit/getvisits?pharmacistid={APIAdmin.Admin.Id}");
ViewBag.Visits = APIAdmin.GetRequest<List<VisitViewModel>>($"api/visit/getvisits?adminid={APIAdmin.Admin.Id}");
ViewBag.Services = APIAdmin.GetRequest<List<ServiceViewModel>>($"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<List<VaccinationViewModel>>($"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<List<VaccinationViewModel>>($"api/vaccination/getvaccin
});
Response.Redirect("Index");
}
public IActionResult Vaccinations()
{
if (APIAdmin.Admin == null)
{
return Redirect("~/Home/Enter");
}
var res = APIAdmin.GetRequest<List<VaccinationViewModel>>($"api/vaccination/getvaccinations?pharmacistid={APIAdmin.Admin.Id}");
return
View(res);
}
public IActionResult UpdateVaccination()
{
if (APIAdmin.Admin == null)
@ -469,27 +480,42 @@ View(APIAdmin.GetRequest<List<VaccinationViewModel>>($"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<List<VaccinationViewModel>>($"api/vaccination/getvaccin
return default;
}
return result;
}
[HttpGet]
public VaccinationViewModel GetVaccination(int adminId)
{
if (APIAdmin.Admin == null)
{
throw new Exception("Âû êàê ñþäà ïîïàëè? Ñþäà âõîä òîëüêî àâòîðèçîâàííûì");
}
var result = APIAdmin.GetRequest<VaccinationViewModel>($"api/vaccination/getvaccination?adminid={adminId}");
if (result == null)
{
return default;
}
return result;
}
}

View File

@ -16,7 +16,7 @@
<div class="row">
<div class="col-4">Дата:</div>
<div class="col-8">
<input type="date" id="date" name="date" />
<input type="datetime-local" id="date" name="date" />
</div>
</div>
<div class="row">
@ -36,6 +36,5 @@
<input type="submit" value="Создать" class="btn btn-primary" />
</div>
</div>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
</form>

View File

@ -27,7 +27,7 @@
<div class="row">
<div class="col-4">Дата:</div>
<div class="col-8">
<input type="date" id="date" name="date"/>
<input type="datetime-local" id="date" name="date" />
</div>
</div>
<div class="row">
@ -36,23 +36,6 @@
<input type="submit" value="Создать" class="btn btn-primary" />
</div>
</div>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
</form>
<script>
$('#animal').on('change', function () {
check();
});
function check() {
if (snack) {
$.ajax({
method: "POST",
url: "/Home/GetAnimal",
data: { animal: animal },
success: function (result) {
$("#animal").val(result);
}
});
};
}
</script>

View File

@ -33,6 +33,9 @@
<th>
Название
</th>
<th>
Стоимость
</th>
<th>
Дата
</th>

View File

@ -22,16 +22,16 @@
<div class="row">
<div class="col-4">Дата:</div>
<div class="col-8">
<input type="date" id="date" name="date" />
<input type="datetime-local" 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)
@foreach (var service in ViewBag.Services)
{
<option value="@services.Id" data-name="@services.ServiceName">@services.ServiceName</option>
<option value="@service.Id" data-name="@service.ServiceName">@service.ServiceName</option>
}
</select>
</div>
@ -48,14 +48,16 @@
<script>
function check() {
var visit = $('#visit').val();
$("#services option:selected").removeAttr("selected");
if (visit) {
$.ajax({
method: "GET",
url: "/Home/GetVisit",
data: { visitId: visit },
success: function (result) {
$('#name').val(result.item1.vistName);
$('#date').val(result.item1.date);
console.log(result.item2);
$('#name').val(result.item1.nameVisit);
$('#date').val(result.item1.dateVisit);
$.map(result.item2, function (n) {
console.log("#" + n);
$(`option[data-name=${n}]`).attr("selected", "selected")

View File

@ -38,7 +38,7 @@
<div class="row">
<div class="col-4">Дата:</div>
<div class="col-8">
<input type="date" id="date" name="date"/>
<input type="datetime-local" id="date" name="date" />
</div>
</div>
<div class="row">
@ -48,21 +48,23 @@
<script src="~/lib/jquery/dist/jquery.min.js"></script>
</form>
<script>
$('#animal').on('change', function () {
check();
});
function check() {
if (snack) {
var vaccination = $('#vaccination').val();
$("#animal option:selected").removeAttr("selected");
if (vaccination) {
$.ajax({
method: "POST",
method: "GET",
url: "/Home/GetVaccination",
data: { vaccinationId: vaccinationId },
data: { vaccinationId: vaccination },
success: function (result) {
$('#name').val(result.text);
$('#cost').val(result.text);
$('#date').val(result.date);
$(`option[data-name=${result.animalId}]`).attr("selected", "selected")
console.log(result.item2);
$('#name').val(result.nameVaccination);
$('#cost').val(result.costVaccination);
$('#date').val(result.dateStamp);
$(`option[data-name=${result.vaccinationId}]`).attr("selected", "selected")
}
});
};
}

View File

@ -50,7 +50,7 @@
$('#family').val(result.item1.family);
$.map(result.item2, function (n) {
console.log("#" + n);
$("#" + n).attr("selected", "selected")
$(`option[data-name=${n}]`).attr("selected", "selected")
});
}

View File

@ -111,12 +111,11 @@ namespace VetClinicBusinessLogic.BusinessLogics
var element = _vaccinationStorage.GetElement(new VaccinationSearchModel
{
NameVaccination = model.NameVaccination,
DateStamp = model.DateStamp,
AnimalId = model.AnimalId,
AnimalId = model.AnimalId
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Прививка для этого услуги с таким текстом уже есть");
throw new InvalidOperationException("Прививка для этого животного с таким текстом уже есть");
}
}
}

View File

@ -101,7 +101,7 @@ true)
throw new ArgumentNullException("Нет названия визита",
nameof(model.NameVisit));
}
if (model.DateVisit != null)
if (model.DateVisit == null)
{
throw new ArgumentNullException("Нет времени визита",
nameof(model.DateVisit));

View File

@ -10,10 +10,10 @@ namespace VetClinicContracts.BindingModels
public class VaccinationBindingModel : IVaccinationModel
{
public int Id { get; set; }
public int AnimalId { get; set; }
public string NameVaccination { get; set; } = string.Empty;
public double CostVaccination { get; set; }
public DateTime DateStamp { get; set; }
public DateTime DateStamp { get; set; } = DateTime.Now;
public int AnimalId { get; set; }
}
}

View File

@ -52,15 +52,15 @@ namespace VetClinicDataBaseImplement.Implements
public GuidanceViewModel? Update(GuidanceBindingModel model)
{
using var context = new VetClinicDatabase();
var order = context.Guidances.Include(x => x.Service).FirstOrDefault(x => x.Id ==
var element = context.Guidances.Include(x => x.Service).FirstOrDefault(x => x.Id ==
model.Id);
if (order == null)
if (element == null)
{
return null;
}
order.Update(context, model);
element.Update(context, model);
context.SaveChanges();
return order.GetViewModel;
return element.GetViewModel;
}
public GuidanceViewModel? Delete(GuidanceBindingModel model)
{

View File

@ -33,7 +33,7 @@ namespace VetClinicDataBaseImplement.Implements
{
using var context = new VetClinicDatabase();
return context.Vaccinations.Include(x => x.Animal).FirstOrDefault(x => (!model.Id.HasValue || model.Id == x.Id)
&& (!model.AnimalId.HasValue || model.AnimalId == x.AnimalId) && (!model.DateFrom.HasValue || model.DateFrom <= x.DateStamp)
&& (!model.AnimalId.HasValue || model.AnimalId == x.AnimalId) && (string.IsNullOrEmpty(model.NameVaccination) || model.NameVaccination == x.NameVaccination) && (!model.DateFrom.HasValue || model.DateFrom <= x.DateStamp)
&& (!model.DateTo.HasValue || model.DateTo >= x.DateStamp))?.GetViewModel;
}
public VaccinationViewModel? Insert(VaccinationBindingModel model)
@ -51,12 +51,11 @@ namespace VetClinicDataBaseImplement.Implements
public VaccinationViewModel? Update(VaccinationBindingModel model)
{
using var context = new VetClinicDatabase();
var element = context.Vaccinations
.Include(x => x.Animal)
var element = context.Vaccinations.Include(x => x.Animal)
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Vaccinations.Remove(element);
element.Update(context, model);
context.SaveChanges();
return element.GetViewModel;
}
@ -65,7 +64,7 @@ namespace VetClinicDataBaseImplement.Implements
public VaccinationViewModel? Delete(VaccinationBindingModel model)
{
using var context = new VetClinicDatabase();
var element = context.Vaccinations.FirstOrDefault(rec => rec.Id ==
var element = context.Vaccinations.Include(x => x.Animal).FirstOrDefault(rec => rec.Id ==
model.Id);
if (element != null)
{

View File

@ -41,7 +41,7 @@ namespace VetClinicDataBaseImplement.Models
};
}
public void Update(VaccinationBindingModel? model)
public void Update(VetClinicDatabase context, VaccinationBindingModel? model)
{
if (model == null)
{
@ -50,7 +50,8 @@ namespace VetClinicDataBaseImplement.Models
NameVaccination = model.NameVaccination;
CostVaccination = model.CostVaccination;
DateStamp = model.DateStamp;
AnimalId = model.AnimalId;
Animal = context.Animals.FirstOrDefault(x => x.Id == model.AnimalId);
}
public VaccinationViewModel GetViewModel => new()

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\SQLEXPRESS01;Initial Catalog=VetClinicDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
}
base.OnConfiguring(optionsBuilder);
}

View File

@ -42,7 +42,7 @@ namespace VetClinicRestApi.Controllers
[HttpGet]
public List<AnimalViewModel>? GetAnimalList(int? adminId = null)
{
try
try
{
List<AnimalViewModel> res;
if (!adminId.HasValue)
@ -50,12 +50,12 @@ namespace VetClinicRestApi.Controllers
else
res = _animal.ReadList(new AnimalSearchModel { AdminId = adminId });
foreach (var animal in res)
animal.VisitAnimals = null!;
animal.VisitAnimals = null;
return res;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения списка животного");
_logger.LogError(ex, "Ошибка получения списка животных");
throw;
}
}

View File

@ -18,6 +18,7 @@ namespace VetClinicRestApi.Controllers
_reportPharmacist = reportPharmacist;
_mailWorker = mailWorker;
}
[Microsoft.AspNetCore.Mvc.HttpGet]
public IActionResult Index(ReportLogicPharmacist reportPharmacist)
{
return View();

View File

@ -77,8 +77,6 @@ namespace VetClinicRestApi.Controllers
{
try
{
if (!isConnection)
model.ServiceVisits = null!;
return _visit.Update(model);
}
catch (Exception ex)

View File

@ -6,6 +6,13 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Reports\**" />
<Content Remove="Reports\**" />
<EmbeddedResource Remove="Reports\**" />
<None Remove="Reports\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="8.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
@ -17,8 +24,4 @@
<ProjectReference Include="..\VetClinicDataBaseImplement\VetClinicDataBaseImplement.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Reports\" />
</ItemGroup>
</Project>