Всё, хватит
This commit is contained in:
parent
eccd93918a
commit
531e1312a2
@ -12,15 +12,14 @@ namespace VeterinaryDatabaseImplement.Implements
|
||||
public List<PurchaseViewModel> GetFullList()
|
||||
{
|
||||
using var context = new VeterinaryDatabase();
|
||||
return context.Purchases.Include(x => x.Pets).ThenInclude(x => x.Pet).Include(x => x.Owner)
|
||||
return context.Purchases.Include(x => x.Owner).Include(x => x.Pets).ThenInclude(x => x.Pet)
|
||||
.Include(x => x.Drug).Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<PurchaseViewModel> GetFilteredList(PurchaseSearchModel model)
|
||||
{
|
||||
using var context = new VeterinaryDatabase();
|
||||
return context.Purchases.Include(x => x.Owner).Include(x => x.Pets).ThenInclude(x => x.Pet).Include(x => x.Drug)
|
||||
.Where(x => x.OwnerId == model.OwnerId)
|
||||
return context.Purchases.Where(x => x.OwnerId == model.OwnerId).Include(x => x.Owner).Include(x => x.Pets).ThenInclude(x => x.Pet).Include(x => x.Drug)
|
||||
.Where(x => ((!model.Id.HasValue || x.Id == model.Id) &&
|
||||
(!model.DateCreate.HasValue || x.DateCreate >= model.DateCreate) &&
|
||||
(!model.OwnerId.HasValue || x.OwnerId <= model.OwnerId) &&
|
||||
|
@ -20,13 +20,8 @@ namespace VeterinaryDatabaseImplement.Implements
|
||||
{
|
||||
|
||||
using var context = new VeterinaryDatabase();
|
||||
return context.Visits.Include(x => x.Owner).Include(x => x.Pets).ThenInclude(x => x.Pet).Include(x => x.Doctor)
|
||||
.Where(x => x.OwnerId == model.OwnerId)
|
||||
.Where(x => ((!model.Id.HasValue || x.Id == model.Id) &&
|
||||
(string.IsNullOrEmpty(model.VisitName) || x.VisitName.Contains(model.VisitName)) &&
|
||||
(!model.DateVisit.HasValue || x.DateVisit >= model.DateVisit) &&
|
||||
(!model.OwnerId.HasValue || x.OwnerId <= model.OwnerId) &&
|
||||
(!model.DoctorId.HasValue || x.DoctorId == model.DoctorId)))
|
||||
return context.Visits.Where(x => x.OwnerId == model.OwnerId).Include(x => x.Owner).Include(x => x.Pets).ThenInclude(x => x.Pet).Include(x => x.Doctor)
|
||||
.Where(x => String.IsNullOrEmpty(model.VisitName) || x.VisitName.Contains(model.VisitName)).ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
@ -62,7 +57,6 @@ namespace VeterinaryDatabaseImplement.Implements
|
||||
return null;
|
||||
}
|
||||
visit.Update(model);
|
||||
//visit.UpdateVisits(context, model);
|
||||
context.SaveChanges();
|
||||
return visit.GetViewModel;
|
||||
}
|
||||
|
@ -35,11 +35,11 @@ namespace VeterinaryRestApi.Controllers
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public List<PurchaseViewModel>? GetPurchases()
|
||||
public List<PurchaseViewModel>? GetPurchases(int? ownerId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _purchase.ReadList(null);
|
||||
return _purchase.ReadList(new PurchaseSearchModel { Id = ownerId});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -99,5 +99,18 @@ namespace VeterinaryRestApi.Controllers
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public bool DeleteVisit(VisitBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _visit.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления лекарства");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ namespace VeterinaryShowOwnerApp.Controllers
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(APIOwner.GetRequest<List<VisitViewModel>>($"api/visit/getallvisits?ownerid={APIOwner.Owner.Id}"));
|
||||
return View(APIOwner.GetRequest<List<VisitViewModel>>($"api/visit/getvisits?ownerid={APIOwner.Owner.Id}"));
|
||||
}
|
||||
public IActionResult CreateVisit()
|
||||
{
|
||||
@ -282,7 +282,7 @@ namespace VeterinaryShowOwnerApp.Controllers
|
||||
{
|
||||
Id = visit
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
Response.Redirect("Visits");
|
||||
}
|
||||
public IActionResult UpdateVisit()
|
||||
{
|
||||
@ -314,28 +314,18 @@ namespace VeterinaryShowOwnerApp.Controllers
|
||||
Response.Redirect("Visits");
|
||||
}
|
||||
[HttpGet]
|
||||
public Tuple<VisitViewModel, List<Tuple<string, int>>>? GetVisit(int visitId)
|
||||
public Tuple<VisitViewModel>? GetVisit(int visitId)
|
||||
{
|
||||
if (APIOwner.Owner == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
var result = APIOwner.GetRequest<Tuple<VisitViewModel, List<Tuple<string>>>>($"api/visit/getvisit?visitid={visitId}");
|
||||
var result = APIOwner.GetRequest<Tuple<VisitViewModel>>($"api/visit/getvisit?visitid={visitId}");
|
||||
if (result == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
string table = "";
|
||||
result.Item1.VisitPet.Clear();
|
||||
for (int i = 0; i < result.Item2.Count; i++)
|
||||
{
|
||||
var pet = result.Item2[i].Item1;
|
||||
table += "<tr>";
|
||||
table += $"<td>{pet}</td>";
|
||||
table += "</tr>";
|
||||
}
|
||||
//return Tuple.Create(result.Item1, table);
|
||||
return null;
|
||||
return result;
|
||||
}
|
||||
public IActionResult Purchases()
|
||||
{
|
||||
@ -497,7 +487,7 @@ namespace VeterinaryShowOwnerApp.Controllers
|
||||
table += "<tr>";
|
||||
table += "<th scope=\"col\">Дата</th>";
|
||||
table += "<th scope=\"col\">Животное</th>";
|
||||
table += "<th scope=\"col\">Название посещенияы</th>";
|
||||
table += "<th scope=\"col\">Название посещения</th>";
|
||||
table += "<th scope=\"col\">Лекарство</th>";
|
||||
table += "</tr>";
|
||||
table += "</thead>";
|
||||
|
@ -18,17 +18,6 @@
|
||||
<div class="col-4">Название:</div>
|
||||
<div class="col-8"><input type="text" name="name" id="name" class="form-control" /></div>
|
||||
</div>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Животные
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="table-elements">
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
|
||||
@ -47,7 +36,6 @@
|
||||
data: { visitId: visit },
|
||||
success: function (result) {
|
||||
$('#name').val(result.item1.visitName);
|
||||
$('#table-elements').html(result.item2);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user