Yunusov_Niyaz 2024-05-01 21:18:32 +04:00
commit 2337b39328
4 changed files with 10 additions and 64 deletions

View File

@ -17,7 +17,7 @@ namespace VeterinaryDatabaseImplement.Implements
.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 => ((!model.Id.HasValue || x.Id == model.Id) &&

View File

@ -145,7 +145,7 @@ namespace VeterinaryShowOwnerApp.Controllers
{
return Redirect("~/Home/Enter");
}
ViewBag.Owners = APIOwner.GetRequest<List<PetViewModel>>($"api/pet/getpets?ownerid={APIOwner.Owner.Id}");
ViewBag.Pets = APIOwner.GetRequest<List<PetViewModel>>($"api/pet/getpets?ownerid={APIOwner.Owner.Id}");
return View();
}
[HttpPost]
@ -213,7 +213,6 @@ namespace VeterinaryShowOwnerApp.Controllers
return Redirect("~/Home/Enter");
}
return View(APIOwner.GetRequest<List<VisitViewModel>>($"api/visit/getvisits?ownerid={APIOwner.Owner.Id}"));
}
public IActionResult CreateVisit()
{
@ -246,7 +245,6 @@ namespace VeterinaryShowOwnerApp.Controllers
VisitName = name,
VisitPet = a,
DateVisit = dateTime,
});
Response.Redirect("Index");
}
@ -256,7 +254,7 @@ namespace VeterinaryShowOwnerApp.Controllers
{
return Redirect("~/Home/Enter");
}
ViewBag.Visits = APIOwner.GetRequest<List<VisitViewModel>>($"api/visit/getvisit?ownerid={APIOwner.Owner.Id}");
ViewBag.Visits = APIOwner.GetRequest<List<VisitViewModel>>($"api/visit/getvisits?ownerid={APIOwner.Owner.Id}");
return View();
}
@ -280,7 +278,7 @@ namespace VeterinaryShowOwnerApp.Controllers
return Redirect("~/Home/Enter");
}
ViewBag.Visits = APIOwner.GetRequest<List<VisitViewModel>>($"api/visit/getvisits?ownerid={APIOwner.Owner.Id}");
ViewBag.Pets = APIOwner.GetRequest<List<PetViewModel>>($"api/pet/getpet");
ViewBag.Pets = APIOwner.GetRequest<List<PetViewModel>>($"api/pet/getpets?ownerid={APIOwner.Owner.Id}");
return View();
}
@ -328,7 +326,7 @@ namespace VeterinaryShowOwnerApp.Controllers
{
return Redirect("~/Home/Enter");
}
return View(APIOwner.GetRequest<List<PurchaseViewModel>>($"api/purchase/getpurchase?ownerid={APIOwner.Owner.Id}"));
return View(APIOwner.GetRequest<List<PurchaseViewModel>>($"api/purchase/getpurchases?ownerid={APIOwner.Owner.Id}"));
}
public IActionResult CreatePurchase()
@ -338,6 +336,7 @@ namespace VeterinaryShowOwnerApp.Controllers
return Redirect("~/Home/Enter");
}
ViewBag.Pets = APIOwner.GetRequest<List<PetViewModel>>($"api/pet/getpets");
ViewBag.Drugs = APIOwner.GetRequest<List<DrugViewModel>>($"api/drug/getdrugs");
return View();
}
[HttpPost]
@ -368,63 +367,10 @@ namespace VeterinaryShowOwnerApp.Controllers
[HttpPost]
public double Calc(int count, int drug)
{
var dru = APIOwner.GetRequest<DrugViewModel>($"api/main/getdrug?drugId={drug}"
);
var dru = APIOwner.GetRequest<DrugViewModel>($"api/drug/getdrugs?drugId={drug}");
return count * (dru?.Price ?? 1);
}
public IActionResult DeletePurchase()
{
if (APIOwner.Owner == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Purchases = APIOwner.GetRequest<List<PurchaseViewModel>>($"api/purchase/getpurchases?ownerid={APIOwner.Owner.Id}");
return View();
}
[HttpPost]
public void DeletePurchase(int purchase)
{
if (APIOwner.Owner == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
APIOwner.PostRequest("api/purchase/deletepurchase", new PurchaseBindingModel
{
Id = purchase
});
Response.Redirect("Index");
}
public IActionResult UpdateService()
{
if (APIOwner.Owner == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Purchases = APIOwner.GetRequest<List<PurchaseViewModel>>($"api/purchase/getpurchases?ownerid={APIOwner.Owner.Id}");
ViewBag.Pets = APIOwner.GetRequest<List<PetViewModel>>($"api/pet/getpets");
return View();
}
[HttpPost]
public void UpdatePurchase(int drug, List<int> pets, int count)
{
if (APIOwner.Owner == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
Dictionary<int, IPetModel> a = new Dictionary<int, IPetModel>();
foreach (int pet in pets)
{
a.Add(pet, new PetSearchModel { Id = pet } as IPetModel);
}
APIOwner.PostRequest("api/purchase/updatepurchase", new PurchaseBindingModel
{
OwnerId = APIOwner.Owner.Id,
DrugId = drug,
PurchasePet = a,
Sum = Calc(count, drug)
});
Response.Redirect("Index");
}
[HttpGet]
public Tuple<PurchaseViewModel, List<string>>? GetPurchase(int purchaseId)
{

View File

@ -1,4 +1,4 @@
n@{
@{
ViewData["Title"] = "DeletePet";
}
<div class="text-center">

View File

@ -16,7 +16,7 @@
<p>
<a asp-action="CreateVisit">Создать визит</a>
<a asp-action="UpdateVisit">Изменить визит</a>
<a asp-action="DeleteeVisit">Удалить визит</a>
<a asp-action="DeleteVisit">Удалить визит</a>
</p>
<table class="table">
<thead>