Register/Privacy/Enter
This commit is contained in:
parent
b45b6a1f7c
commit
4b81de1b6c
@ -11,7 +11,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceStationContracts", "
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceStationBusinessLogic", "ServiceStationBusinessLogic\ServiceStationBusinessLogic.csproj", "{E3C21F43-152C-4770-88A9-0CF5B182E6AD}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceStationBusinessLogic", "ServiceStationBusinessLogic\ServiceStationBusinessLogic.csproj", "{E3C21F43-152C-4770-88A9-0CF5B182E6AD}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceStationRestAPI", "ServiceStationRestAPI\ServiceStationRestAPI.csproj", "{6EA674DA-F458-4662-BBE5-7F5C45D5AE5C}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceStationRestAPI", "ServiceStationRestAPI\ServiceStationRestAPI.csproj", "{6EA674DA-F458-4662-BBE5-7F5C45D5AE5C}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServiceSourceExecutorApp", "ServiceStationExecutorApp\ServiceSourceExecutorApp.csproj", "{85655746-80E9-4B8B-A0B6-94DF0B7E9339}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -39,6 +41,10 @@ Global
|
|||||||
{6EA674DA-F458-4662-BBE5-7F5C45D5AE5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{6EA674DA-F458-4662-BBE5-7F5C45D5AE5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{6EA674DA-F458-4662-BBE5-7F5C45D5AE5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{6EA674DA-F458-4662-BBE5-7F5C45D5AE5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{6EA674DA-F458-4662-BBE5-7F5C45D5AE5C}.Release|Any CPU.Build.0 = Release|Any CPU
|
{6EA674DA-F458-4662-BBE5-7F5C45D5AE5C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{85655746-80E9-4B8B-A0B6-94DF0B7E9339}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{85655746-80E9-4B8B-A0B6-94DF0B7E9339}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{85655746-80E9-4B8B-A0B6-94DF0B7E9339}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{85655746-80E9-4B8B-A0B6-94DF0B7E9339}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using ServiceSourceClientApp.Models;
|
|
||||||
using System.Diagnostics;
|
|
||||||
|
|
||||||
namespace ServiceSourceClientApp.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();
|
|
||||||
}
|
|
||||||
|
|
||||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
|
||||||
public IActionResult Error() {
|
|
||||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
42
ServiceStation/ServiceStationExecutorApp/APIClient.cs
Normal file
42
ServiceStation/ServiceStationExecutorApp/APIClient.cs
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
using ServiceStationContracts.ViewModels;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ServiceSourceExecutorApp {
|
||||||
|
public class APIClient {
|
||||||
|
private static readonly HttpClient _client = new();
|
||||||
|
public static ExecutorViewModel? executor { get; set; } = null;
|
||||||
|
public static string port { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public static void Connect(IConfiguration configuration) {
|
||||||
|
_client.BaseAddress = new Uri(configuration["IPAddress"]);
|
||||||
|
port = _client.BaseAddress.Port.ToString();
|
||||||
|
_client.DefaultRequestHeaders.Accept.Clear();
|
||||||
|
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static T? GetRequest<T>(string requestUrl) {
|
||||||
|
var response = _client.GetAsync(requestUrl);
|
||||||
|
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||||
|
if (response.Result.IsSuccessStatusCode) {
|
||||||
|
return JsonConvert.DeserializeObject<T>(result);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new Exception(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void PostRequest<T>(string requestUrl, T model) {
|
||||||
|
var json = JsonConvert.SerializeObject(model);
|
||||||
|
var data = new StringContent(json, Encoding.UTF8, "application/json");
|
||||||
|
|
||||||
|
var response = _client.PostAsync(requestUrl, data);
|
||||||
|
|
||||||
|
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||||
|
if (!response.Result.IsSuccessStatusCode) {
|
||||||
|
throw new Exception(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,96 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Formatters;
|
||||||
|
using ServiceSourceClientApp.Models;
|
||||||
|
using ServiceSourceExecutorApp;
|
||||||
|
using ServiceStationContracts.BindingModels;
|
||||||
|
using ServiceStationContracts.ViewModels;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace ServiceSourceClientApp.Controllers {
|
||||||
|
public class HomeController : Controller {
|
||||||
|
private readonly ILogger<HomeController> _logger;
|
||||||
|
|
||||||
|
public HomeController(ILogger<HomeController> logger) {
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Index() {
|
||||||
|
if (APIClient.executor == null) {
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Enter() {
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void Enter(string email, string password) {
|
||||||
|
if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) {
|
||||||
|
throw new Exception("Ââåäèòå ïî÷òó è ïàðîëü");
|
||||||
|
}
|
||||||
|
APIClient.executor = APIClient.GetRequest<ExecutorViewModel>($"api/main/Login?email={email}&password={password}");
|
||||||
|
if (APIClient.executor == null) {
|
||||||
|
throw new Exception("Íåâåðíûé àäðåñ ïî÷òû èëè ïàðîëü");
|
||||||
|
}
|
||||||
|
Response.Redirect("Index");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Register() {
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
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/Main/Register", new ExecutorBindingModel {
|
||||||
|
Email = email,
|
||||||
|
Password = password,
|
||||||
|
FIO = fio
|
||||||
|
});
|
||||||
|
Response.Redirect("Enter");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Privacy() {
|
||||||
|
if (APIClient.executor == null) {
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
return View(APIClient.executor);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void Privacy(string email, string password, string fio) {
|
||||||
|
if (APIClient.executor == null) {
|
||||||
|
Response.Redirect("~/Home/Enter");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio)) {
|
||||||
|
throw new Exception("Ââåäèòå ïî÷òó, ïàðîëü è ÔÈÎ");
|
||||||
|
}
|
||||||
|
APIClient.PostRequest("api/Main/UpdateData", new ExecutorBindingModel {
|
||||||
|
Id = APIClient.executor.Id,
|
||||||
|
Email = email,
|
||||||
|
Password = password,
|
||||||
|
FIO = fio
|
||||||
|
});
|
||||||
|
|
||||||
|
APIClient.executor.FIO = fio;
|
||||||
|
APIClient.executor.Email = email;
|
||||||
|
APIClient.executor.Password = password;
|
||||||
|
Response.Redirect("Index");
|
||||||
|
}
|
||||||
|
|
||||||
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||||
|
public IActionResult Error() {
|
||||||
|
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +1,5 @@
|
|||||||
|
using ServiceSourceExecutorApp;
|
||||||
|
|
||||||
namespace ServiceSourceClientApp {
|
namespace ServiceSourceClientApp {
|
||||||
public class Program {
|
public class Program {
|
||||||
public static void Main(string[] args) {
|
public static void Main(string[] args) {
|
||||||
@ -7,6 +9,7 @@ namespace ServiceSourceClientApp {
|
|||||||
builder.Services.AddControllersWithViews();
|
builder.Services.AddControllersWithViews();
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
APIClient.Connect(builder.Configuration);
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
if (!app.Environment.IsDevelopment()) {
|
if (!app.Environment.IsDevelopment()) {
|
@ -0,0 +1,17 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\ServiceStationContracts\ServiceStationContracts.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -0,0 +1,21 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Enter";
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Вход в приложение</h2>
|
||||||
|
</div>
|
||||||
|
<form method="post">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Почта:</div>
|
||||||
|
<div class="col-8"><input type="text" name="Email" /></div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Пароль:</div>
|
||||||
|
<div class="col-8"><input type="password" name="password" /></div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-8"></div>
|
||||||
|
<div class="col-4"><input type="submit" value="Вход" class="btn btn-primary" /></div>
|
||||||
|
</div>
|
||||||
|
</form>
|
@ -1,25 +1,24 @@
|
|||||||
@{
|
@using ServiceStationContracts.ViewModels
|
||||||
|
@{
|
||||||
ViewData["Title"] = "Privacy Policy";
|
ViewData["Title"] = "Privacy Policy";
|
||||||
}
|
}
|
||||||
|
@model ExecutorViewModel
|
||||||
|
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h2 class="display-4">Личные данные</h2>
|
<h2 class="display-4">Личные данные</h2>
|
||||||
</div>
|
</div>
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Логин:</div>
|
<div class="col-4">Почта:</div>
|
||||||
<div class="col-8"><input type="text" name="login" value="@Model.Email"/></div>
|
<div class="col-8"><input type="text" name="email" value="@Model.Email"/></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Пароль:</div>
|
<div class="col-4">Пароль:</div>
|
||||||
<div class="col-8"><input type="password" name="password" value="@Model.Password"/></div>
|
<div class="col-8"><input type="password" name="password" value="@Model.Password"/></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Пароль:</div>
|
<div class="col-4">ФИО:</div>
|
||||||
<div class="col-8"><input type="text" name="phone number" value="@Model.PhoneNumber"/></div>
|
<div class="col-8"><input type="text" name="fio" value="@Model.FIO"/></div>
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-4">логин:</div>
|
|
||||||
<div class="col-8"><input type="text" name="fio" value="@Model.Login"/></div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-8"></div>
|
<div class="col-8"></div>
|
@ -7,24 +7,19 @@
|
|||||||
</div>
|
</div>
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Логин:</div>
|
<div class="col-4">Почта:</div>
|
||||||
<div class="col-8"><input type="text" name="login" /></div>
|
<div class="col-8"><input type="text" name="Email" /></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Пароль:</div>
|
<div class="col-4">Пароль:</div>
|
||||||
<div class="col-8"><input type="password" name="password" /></div>
|
<div class="col-8"><input type="password" name="password" /></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Имя:</div>
|
<div class="col-4">ФИО:</div>
|
||||||
<div class="col-8"><input type="text" name="Имя" /></div>
|
<div class="col-8"><input type="text" name="fio" /></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
|
||||||
<div class="col-4">Фамилия:</div>
|
|
||||||
<div class="col-8"><input type="text" name="Фамилия" /></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-8"></div>
|
<div class="col-8"></div>
|
||||||
<div class="col-4"><input type="submit" value="Регистрация" class="btn btn-primary" /></div>
|
<div class="col-4"><input type="submit" value="Регистрация" class="btn btn-primary" /></div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
@ -12,7 +12,7 @@
|
|||||||
<header>
|
<header>
|
||||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">ServiceSourceExecutorApp</a>
|
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">СТО Руки-крюки (Исполнитель)</a>
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
||||||
aria-expanded="false" aria-label="Toggle navigation">
|
aria-expanded="false" aria-label="Toggle navigation">
|
||||||
<span class="navbar-toggler-icon"></span>
|
<span class="navbar-toggler-icon"></span>
|
@ -7,6 +7,5 @@
|
|||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
// порт -> Свойства/отладка/пользовательский ин./URL адресс
|
// порт -> Свойства/отладка/пользовательский ин./URL адресс
|
||||||
"IPAddress": "http://localhost:5176/"
|
"IPAddress": "http://localhost:5192/"
|
||||||
|
|
||||||
}
|
}
|
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.3 KiB |
Loading…
x
Reference in New Issue
Block a user