2024-04-23 15:58:02 +04:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using System.Diagnostics;
|
2024-05-26 23:51:13 +04:00
|
|
|
|
using System.Reflection.Metadata;
|
2024-04-23 15:58:02 +04:00
|
|
|
|
using UniversityClientApp.Models;
|
2024-05-26 16:22:04 +04:00
|
|
|
|
using UniversityClientAppStorekeeper;
|
|
|
|
|
using UniversityContracts.BindingModels;
|
|
|
|
|
using UniversityContracts.ViewModels;
|
|
|
|
|
using UniversityDataModels.Enums;
|
2024-04-23 15:58:02 +04:00
|
|
|
|
|
|
|
|
|
namespace UniversityClientApp.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class HomeController : Controller
|
|
|
|
|
{
|
|
|
|
|
private readonly ILogger<HomeController> _logger;
|
|
|
|
|
|
|
|
|
|
public HomeController(ILogger<HomeController> logger)
|
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult Index()
|
|
|
|
|
{
|
2024-05-26 22:28:34 +04:00
|
|
|
|
if (APIStorekeeper.Client == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
|
|
|
|
//return View(APIStorekeeper.GetRequest<List<OrderViewModel>>($"api/main/getorders?clientId={APIClient.Client.Id}"));
|
|
|
|
|
return View();
|
|
|
|
|
}
|
2024-04-23 15:58:02 +04:00
|
|
|
|
|
|
|
|
|
public IActionResult Privacy()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-26 16:22:04 +04:00
|
|
|
|
[HttpGet]
|
2024-04-28 16:30:27 +04:00
|
|
|
|
public IActionResult Enter()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
2024-05-26 16:22:04 +04:00
|
|
|
|
[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>");
|
|
|
|
|
}
|
|
|
|
|
APIStorekeeper.Client = APIStorekeeper.GetRequest<UserViewModel>($"api/user/loginstorekeeper?login={login}&password={password}");
|
|
|
|
|
if (APIStorekeeper.Client == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
Response.Redirect("Index");
|
|
|
|
|
}
|
|
|
|
|
[HttpGet]
|
|
|
|
|
public IActionResult Register()
|
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Register(string login, string password, string email)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(email))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
APIStorekeeper.PostRequest("api/user/registerstorekeeper", new UserBindingModel
|
|
|
|
|
{
|
|
|
|
|
Login = login,
|
|
|
|
|
Email = email,
|
|
|
|
|
Password = password,
|
|
|
|
|
Role = UserRole.<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("Enter");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-04-28 16:30:27 +04:00
|
|
|
|
|
2024-05-26 16:22:04 +04:00
|
|
|
|
public IActionResult Disciplines()
|
2024-04-28 16:30:27 +04:00
|
|
|
|
{
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult Statements()
|
|
|
|
|
{
|
2024-05-26 23:51:13 +04:00
|
|
|
|
if (APIStorekeeper.Client == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
|
|
|
|
return View(APIStorekeeper.GetRequest<List<StatementViewModel>>($"api/statement/getstatements?teacherId={0}"));
|
2024-04-28 16:30:27 +04:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-26 23:51:13 +04:00
|
|
|
|
[HttpGet]
|
|
|
|
|
public IActionResult Teachers()
|
2024-04-28 16:30:27 +04:00
|
|
|
|
{
|
2024-05-26 23:51:13 +04:00
|
|
|
|
if (APIStorekeeper.Client == null)
|
|
|
|
|
{
|
|
|
|
|
return Redirect("~/Home/Enter");
|
|
|
|
|
}
|
|
|
|
|
//ViewBag.Documents = APIStorekeeper.GetRequest<List<DisciplineViewModel>>("api/main/getdiscipline");
|
|
|
|
|
return View(APIStorekeeper.GetRequest<List<TeacherViewModel>>($"api/teacher/getteachers?userId={APIStorekeeper.Client.Id}"));
|
|
|
|
|
}
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public void Teachers(string name, string position, string academicDegree)
|
|
|
|
|
{
|
|
|
|
|
if (APIStorekeeper.Client == null)
|
|
|
|
|
{
|
|
|
|
|
Redirect("~/Home/Enter");
|
|
|
|
|
}
|
|
|
|
|
APIStorekeeper.PostRequest("api/teacher/createteacher", new TeacherBindingModel
|
|
|
|
|
{
|
|
|
|
|
UserId = APIStorekeeper.Client.Id,
|
|
|
|
|
Name = name,
|
|
|
|
|
Position = position,
|
|
|
|
|
AcademicDegree = academicDegree
|
|
|
|
|
});
|
|
|
|
|
Response.Redirect("Index");
|
|
|
|
|
}
|
2024-04-28 16:30:27 +04:00
|
|
|
|
|
2024-05-26 23:51:13 +04:00
|
|
|
|
public IActionResult Report() {
|
2024-04-28 16:30:27 +04:00
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
2024-04-23 15:58:02 +04:00
|
|
|
|
public IActionResult Error()
|
|
|
|
|
{
|
|
|
|
|
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|