211 lines
5.0 KiB
C#
211 lines
5.0 KiB
C#
using ComputerHardwareStoreContracts.BindingModels;
|
|
using ComputerHardwareStoreContracts.ViewModels;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System.Diagnostics;
|
|
using VendorClient.Models;
|
|
|
|
namespace VendorClient.Controllers
|
|
{
|
|
public class HomeController : Controller
|
|
{
|
|
private readonly ILogger<HomeController> _logger;
|
|
|
|
public HomeController(ILogger<HomeController> logger)
|
|
{
|
|
_logger = logger;
|
|
}
|
|
|
|
[HttpGet]
|
|
public IActionResult Index()
|
|
{
|
|
if (APIClient.Vendor == null)
|
|
{
|
|
return Redirect("~/Home/Enter");
|
|
}
|
|
|
|
return View(APIClient.Vendor);
|
|
}
|
|
|
|
[HttpGet]
|
|
public IActionResult Privacy()
|
|
{
|
|
if (APIClient.Vendor == null)
|
|
{
|
|
return Redirect("~/Home/Enter");
|
|
}
|
|
return View(APIClient.Vendor);
|
|
}
|
|
|
|
[HttpPost]
|
|
public void Privacy(string login, string password, string fio)
|
|
{
|
|
if (APIClient.Vendor == null)
|
|
{
|
|
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
|
}
|
|
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio))
|
|
{
|
|
throw new Exception("Введите логин, пароль и ФИО");
|
|
}
|
|
APIClient.PostRequest("api/vendor/updatedata", new VendorBindingModel
|
|
{
|
|
Id = APIClient.Vendor.Id,
|
|
Name = fio,
|
|
Login = login,
|
|
Password = password
|
|
});
|
|
APIClient.Vendor.Name = fio;
|
|
APIClient.Vendor.Login = login;
|
|
APIClient.Vendor.Password = password;
|
|
Response.Redirect("Index");
|
|
}
|
|
|
|
[HttpGet]
|
|
public IActionResult Enter()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[HttpPost]
|
|
public void Enter(string login, string password)
|
|
{
|
|
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
|
|
{
|
|
throw new Exception("Введите почту и пароль");
|
|
}
|
|
APIClient.Vendor = APIClient.GetRequest<VendorViewModel>($"api/vendor/login?login={login}&password={password}");
|
|
if (APIClient.Vendor == null)
|
|
{
|
|
throw new Exception("Неверные почта и/или пароль");
|
|
}
|
|
Response.Redirect("Index");
|
|
return;
|
|
}
|
|
|
|
[HttpGet]
|
|
public IActionResult Register()
|
|
{
|
|
|
|
return View();
|
|
}
|
|
[HttpPost]
|
|
public void Register(string name, string login, string password)
|
|
{
|
|
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(name) || string.IsNullOrEmpty(password))
|
|
{
|
|
throw new Exception("Введите логин, name, пароль");
|
|
}
|
|
APIClient.PostRequest("api/vendor/register", new VendorBindingModel
|
|
{
|
|
Name = name,
|
|
Login = login,
|
|
Password = password,
|
|
});
|
|
Response.Redirect("Enter");
|
|
return;
|
|
}
|
|
|
|
[HttpGet]
|
|
public IActionResult AddBuildToPurchase()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[HttpGet]
|
|
public IActionResult Builds()
|
|
{
|
|
return View(new List<BuildViewModel>());
|
|
}
|
|
|
|
[HttpGet]
|
|
public IActionResult BuildCreate()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[HttpGet]
|
|
public IActionResult BuildDelete()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[HttpGet]
|
|
public IActionResult BuildUpdate()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[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<CommentViewModel>());
|
|
}
|
|
|
|
[HttpGet]
|
|
public IActionResult ProductsList()
|
|
{
|
|
return View(new List<BuildViewModel>());
|
|
}
|
|
|
|
[HttpGet]
|
|
public IActionResult PurchaseCreate()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[HttpGet]
|
|
public IActionResult PurchaseDelete()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[HttpGet]
|
|
public IActionResult Purchases()
|
|
{
|
|
return View(new List<PurchaseViewModel>());
|
|
}
|
|
|
|
[HttpGet]
|
|
public IActionResult PurchaseUpdate()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[HttpGet]
|
|
public IActionResult Report()
|
|
{
|
|
return View(new List<PurchaseViewModel>());
|
|
}
|
|
|
|
[HttpPost]
|
|
public void Report(string password)
|
|
{
|
|
Response.Redirect("ReportOnly");
|
|
}
|
|
|
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
|
public IActionResult Error()
|
|
{
|
|
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
|
}
|
|
}
|
|
}
|