в предвкушении отчетов
This commit is contained in:
parent
1c2e4527cf
commit
a25a89df66
@ -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) &&
|
||||
|
@ -20,7 +20,7 @@ namespace VeterinaryDatabaseImplement.Implements
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.VisitName))
|
||||
{
|
||||
return null;
|
||||
return new();
|
||||
}
|
||||
using var context = new VeterinaryDatabase();
|
||||
return context.Visits.Include(x => x.Owner).Include(x => x.Pets).ThenInclude(x => x.Pet).Include(x => x.Doctor)
|
||||
|
@ -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()
|
||||
{
|
||||
@ -221,7 +220,7 @@ namespace VeterinaryShowOwnerApp.Controllers
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Pets = APIOwner.GetRequest<List<PetViewModel>>($"api/pet/getpet?ownerid={APIOwner.Owner.Id}");
|
||||
ViewBag.Pets = APIOwner.GetRequest<List<PetViewModel>>($"api/pet/getpets?ownerid={APIOwner.Owner.Id}");
|
||||
|
||||
return View();
|
||||
}
|
||||
@ -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)
|
||||
{
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user