PIbd-21_BatylkinaAO_MusoevD.../Canteen/CanteenVisitorApp/Controllers/HomeController.cs
2023-05-18 00:40:11 +03:00

88 lines
2.3 KiB
C#

using CanteenContracts.BindingModels;
using CanteenContracts.View;
using CanteenVisitorApp.Models;
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
namespace CanteenVisitorApp.Controllers
{
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
}
public IActionResult Index()
{
return View();
}
public IActionResult Privacy()
{
return View();
}
public IActionResult Lunches()
{
ViewBag.Cooks = APIClient.GetRequest<List<LunchViewModel>>("api/main/getcooklist");
ViewBag.Lunches = new List<LunchViewModel>();
return View();
}
[HttpGet]
public IActionResult Tablewares()
{
ViewBag.Tablewares = APIClient.GetRequest<List<TablewareViewModel>>("api/main/gettablewarelist");
return View();
}
[HttpGet]
public IActionResult Orders()
{
ViewBag.Orders = new List<OrderViewModel>();
return View();
}
[HttpGet]
public IActionResult CreateOrder()
{
ViewBag.Dishes = new List<DishViewModel>();
return View();
}
[HttpGet]
public IActionResult CreateLunch()
{
ViewBag.Products = new List<ProductViewModel>();
return View();
}
[HttpPost]
public void CreateTableware(string TablewareName, int TablewareCount)
{
APIClient.PostRequest("api/main/CreateTableware", new TablewareBindingModel
{
VisitorId = 1,
TablewareName = TablewareName
});
Response.Redirect("Tablewares");
}
[HttpGet]
public IActionResult CreateTableware()
{
ViewBag.Orders = new List<OrderViewModel>();
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}