using ComputerHardwareStoreContracts.BindingModels; using ComputerHardwareStoreContracts.ViewModels; using Microsoft.AspNetCore.Mvc; using System.Diagnostics; using VendorClient.Models; namespace VendorClient.Controllers { [Route("Home/[action]")] public class HomeController : Controller { private readonly ILogger _logger; public HomeController(ILogger logger) { _logger = logger; } [HttpGet] public IActionResult Index() { if (APIClient.Vendor == null) { return Redirect("~/Home/Enter"); } return View(); } [HttpGet] public IActionResult Privacy() { if (APIClient.Vendor == null) { return Redirect("~/Home/Enter"); } return View(APIClient.Vendor); } [HttpGet] public void Enter(string email, string password) { if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) { throw new Exception("Введите почту и пароль"); } APIClient.Vendor = APIClient.GetRequest($"api/vendor/login?email={email}&password={password}"); if (APIClient.Vendor == null) { throw new Exception("Неверные почта и/или пароль"); } Response.Redirect("MainWorker"); } [HttpGet] public void Register(string email, string password, string fio) { if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio)) { throw new Exception("Введите логин, пароль и ФИО"); } APIClient.PostRequest("api/pharmacist/register", new VendorBindingModel { Name = fio, Login = email, Password = password }); Response.Redirect("~/Home/Enter"); return; } [HttpGet] public IActionResult CommentCreate() { return View(); } [HttpGet] public IActionResult CommentDelete() { return View(); } [HttpGet] public IActionResult CommentUpdate() { return View(); } [HttpGet] public IActionResult Comments() { return View(new List()); } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() { return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); } } }