2024-11-06 01:27:34 +04:00
|
|
|
|
using CandidateReviewClientApp;
|
|
|
|
|
using CandidateReviewClientApp.Models;
|
|
|
|
|
using CandidateReviewContracts.BindingModels;
|
|
|
|
|
using CandidateReviewContracts.ViewModels;
|
2024-11-18 23:37:50 +04:00
|
|
|
|
using CandidateReviewDataModels.Enums;
|
2024-11-06 01:27:34 +04:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
|
|
|
|
namespace CandidateReviewUserApp.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class HomeController : Controller
|
|
|
|
|
{
|
|
|
|
|
private readonly ILogger<HomeController> _logger;
|
|
|
|
|
|
|
|
|
|
public HomeController(ILogger<HomeController> logger)
|
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult Index()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public IActionResult Enter()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Enter(string login, string password)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
APIClient.User = APIClient.GetRequest<UserViewModel>($"api/user/login?login={login}&password={password}");
|
|
|
|
|
if (APIClient.User == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
2024-11-23 21:39:18 +04:00
|
|
|
|
if (APIClient.User?.CompanyId != null)
|
|
|
|
|
{
|
|
|
|
|
APIClient.Company = APIClient.GetRequest<CompanyViewModel>($"api/company/profile?id={APIClient.User?.CompanyId}");
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-18 23:37:50 +04:00
|
|
|
|
Response.Redirect("/Home/Index");
|
2024-11-06 01:27:34 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public IActionResult Register()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
2024-11-18 23:37:50 +04:00
|
|
|
|
|
2024-11-06 01:27:34 +04:00
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Register(string login, string password, string surname, string name, string lastname)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(surname) || string.IsNullOrEmpty(name))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD>");
|
|
|
|
|
}
|
2024-11-18 23:37:50 +04:00
|
|
|
|
|
|
|
|
|
RoleEnum role = RoleEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|
|
|
|
|
|
|
|
|
if (login.Equals("tania.art03@gmail.com", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
2024-11-23 21:39:18 +04:00
|
|
|
|
role = RoleEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
2024-11-18 23:37:50 +04:00
|
|
|
|
}
|
|
|
|
|
else if (login.Equals("t.artamonova73@icloud.com", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
role = RoleEnum.<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-06 01:27:34 +04:00
|
|
|
|
APIClient.PostRequest("api/user/register", new UserBindingModel
|
|
|
|
|
{
|
|
|
|
|
Surname = surname,
|
|
|
|
|
Name = name,
|
|
|
|
|
LastName = lastname ?? null,
|
|
|
|
|
Email = login,
|
|
|
|
|
Password = password,
|
|
|
|
|
EmailConfirmed = false,
|
2024-11-18 23:37:50 +04:00
|
|
|
|
Role = role
|
2024-11-06 01:27:34 +04:00
|
|
|
|
});
|
2024-11-18 23:37:50 +04:00
|
|
|
|
|
|
|
|
|
Response.Redirect("/Home/Enter");
|
2024-11-06 01:27:34 +04:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
|
|
|
|
public IActionResult Error()
|
|
|
|
|
{
|
|
|
|
|
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|