Правлю

This commit is contained in:
gg12 darfren 2024-04-29 22:29:35 +04:00
parent 04961cbd72
commit 904264de3d
6 changed files with 18 additions and 10 deletions

View File

@ -275,7 +275,7 @@ View(APIPharmacist.GetRequest<List<MedicineViewModel>>($"api/medicine/getmedicin
Dictionary<int, IAnimalModel> a = new Dictionary<int, IAnimalModel>();
foreach (int animal in animals)
{
a.Add(animal, new AnimalSearchModel { Id = animal } as IAnimalModel);
a.Add(animal, new AnimalBindingModel { Id = animal } as IAnimalModel);
}
APIPharmacist.PostRequest("api/medicine/updatemedicine?isconnection=true", new MedicineBindingModel
{
@ -376,7 +376,7 @@ View(APIPharmacist.GetRequest<List<ServiceViewModel>>($"api/service/getservices?
Dictionary<int, IMedicineModel> a = new Dictionary<int, IMedicineModel>();
foreach (int medicine in medicines)
{
a.Add(medicine, new AnimalSearchModel { Id = medicine } as IMedicineModel);
a.Add(medicine, new MedicineBindingModel { Id = medicine } as IMedicineModel);
}
APIPharmacist.PostRequest("api/service/createservice", new ServiceBindingModel

View File

@ -93,10 +93,14 @@ namespace VetClinicDataBaseImplement.Models
{
var visitAnimals = context.VisitAnimals.Where(rec => rec.AnimalId == model.Id).ToList();
if (visitAnimals != null)
{ // удалили те, которых нет в модели
{
context.VisitAnimals.RemoveRange(visitAnimals.Where(rec => !model.VisitAnimals.ContainsKey(rec.VisitId)));
context.SaveChanges();
foreach (var visit in visitAnimals)
{
model.VisitAnimals.Remove(visit.VisitId);
}
context.SaveChanges();
}
var animal = context.Animals.First(x => x.Id == Id);
foreach (var pc in model.VisitAnimals)

View File

@ -95,7 +95,11 @@ namespace VetClinicDataBaseImplement.Models
{ // удалили те, которых нет в модели
context.ServiceVisits.RemoveRange(serviceVisits.Where(rec => !model.ServiceVisits.ContainsKey(rec.ServiceId)));
context.SaveChanges();
foreach (var service in serviceVisits)
{
model.ServiceVisits.Remove(service.ServiceId);
}
context.SaveChanges();
}
var visit = context.Visits.First(x => x.Id == Id);
foreach (var pc in model.ServiceVisits)

View File

@ -29,7 +29,7 @@ namespace VetClinicRestApi.Controllers
if (elem == null)
return null;
var res = Tuple.Create(elem, elem.VisitAnimals.Select(x => x.Value.NameVisit).ToList());
res.Item1.VisitAnimals = null;
res.Item1.VisitAnimals = null!;
return res;
}
catch (Exception ex)
@ -46,7 +46,7 @@ namespace VetClinicRestApi.Controllers
{
var res = _animal.ReadList(new AnimalSearchModel { AdminId = adminId });
foreach (var animal in res)
animal.VisitAnimals = null;
animal.VisitAnimals = null!;
return res;
}
catch (Exception ex)

View File

@ -27,8 +27,6 @@ namespace VetClinicRestApi.Controllers
try
{
var elem = _guidance.ReadElement(new GuidanceSearchModel { Id = guidanceId });
if (elem == null)
return null;
return elem;
}
catch (Exception ex)

View File

@ -23,10 +23,12 @@ namespace VetClinicRestApi.Controllers
}
[HttpGet]
public List<VaccinationViewModel>? GetVaccinations(int animalId)
public List<VaccinationViewModel>? GetVaccinations(int? animalId)
{
try
{
if (!animalId.HasValue)
return _vaccination.ReadList(null);
return _vaccination.ReadList(new VaccinationSearchModel
{
AnimalId = animalId