Лабораторная работа 5. Еще раз вставлен текст HomeController (фикс отобращения страницы заказов в ClientAPI).

This commit is contained in:
ksenianeva 2023-04-28 10:09:23 +04:00
parent 402ac49b12
commit 1eea7331e4

View File

@ -1,12 +1,12 @@
using TravelCompanyContracts.BindingModels; using Microsoft.AspNetCore.Mvc;
using TravelCompanyContracts.ViewModels;
using TravelCompanyClientApp.Models;
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
using TravelCompanyClientApp;
using PrecastConcretePlantClientApp; using PrecastConcretePlantClientApp;
using System.Diagnostics;
using TravelCompanyClientApp.Models;
using TravelCompanyContracts.BindingModels;
using TravelCompanyContracts.ViewModels;
namespace TravelCompanyClientApp.Controllers
namespace AbstractShowClientApp.Controllers
{ {
public class HomeController : Controller public class HomeController : Controller
{ {
@ -76,7 +76,8 @@ namespace TravelCompanyClientApp.Controllers
[HttpPost] [HttpPost]
public void Enter(string login, string password) public void Enter(string login, string password)
{ {
if (string.IsNullOrEmpty(login) ||string.IsNullOrEmpty(password)) if (string.IsNullOrEmpty(login) ||
string.IsNullOrEmpty(password))
{ {
throw new Exception("Введите логин и пароль"); throw new Exception("Введите логин и пароль");
} }
@ -101,7 +102,8 @@ namespace TravelCompanyClientApp.Controllers
{ {
throw new Exception("Введите логин, пароль и ФИО"); throw new Exception("Введите логин, пароль и ФИО");
} }
APIClient.PostRequest("api/client/register", new ClientBindingModel APIClient.PostRequest("api/client/register", new
ClientBindingModel
{ {
ClientFIO = fio, ClientFIO = fio,
Email = login, Email = login,
@ -114,7 +116,7 @@ namespace TravelCompanyClientApp.Controllers
public IActionResult Create() public IActionResult Create()
{ {
ViewBag.Products = ViewBag.Products =
APIClient.GetRequest<List<TravelViewModel>>("api/main/gettravellist"); APIClient.GetRequest<List<TravelViewModel>>("api/main/getproductlist");
return View(); return View();
} }
[HttpPost] [HttpPost]
@ -142,7 +144,7 @@ namespace TravelCompanyClientApp.Controllers
public double Calc(int count, int travel) public double Calc(int count, int travel)
{ {
var prod = var prod =
APIClient.GetRequest<TravelViewModel>($"api/main/gettravel?travelId={travel}" APIClient.GetRequest<TravelViewModel>($"api/main/getproduct?travelId={travel}"
); );
return count * (prod?.Price ?? 1); return count * (prod?.Price ?? 1);
} }