Edit WebApp layout

This commit is contained in:
ShabOl 2024-05-28 13:22:24 +04:00
parent 525d9fe140
commit 1f7fb4f849
6 changed files with 97 additions and 25 deletions

View File

@ -0,0 +1,49 @@
using ComputerShopContracts.ViewModels;
using Newtonsoft.Json;
using System.Net.Http.Headers;
using System.Text;
namespace ComputerShopGuarantorApp
{
public static class ApiUser
{
private static readonly HttpClient _client = new();
public static UserViewModel? User { get; set; } = null;
public static void Connect(IConfiguration Configuration)
{
_client.BaseAddress = new Uri(Configuration["IPAddress"]);
_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);
}
}
}
}

View File

@ -6,4 +6,12 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ComputerShopContracts\ComputerShopContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -1,27 +1,30 @@
var builder = WebApplication.CreateBuilder(args);
using ComputerShopGuarantorApp;
var Builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllersWithViews();
Builder.Services.AddControllersWithViews();
var app = builder.Build();
var App = Builder.Build();
ApiUser.Connect(Builder.Configuration);
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
if (!App.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
App.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
App.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
App.UseHttpsRedirection();
App.UseStaticFiles();
app.UseRouting();
App.UseRouting();
app.UseAuthorization();
App.UseAuthorization();
app.MapControllerRoute(
App.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run();
App.Run();

View File

@ -3,34 +3,40 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - ComputerShopGuarantorApp</title>
<title>@ViewData["Title"] - Поручитель</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/ComputerShopGuarantorApp.styles.css" asp-append-version="true" />
</head>
<body>
<body class="d-flex flex-column min-vh-100" padding="56px">
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container-fluid">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">ComputerShopGuarantorApp</a>
<nav class="navbar fixed-top navbar-expand-lg navbar-dark bg-dark">
<div class="container-md">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index"><span class="fw-bold text-uppercase ms-2">Приложение поручителя</span></a>
<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">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
<div class="collapse navbar-collapse justify-content-end align-center" id="main-nav">
<ul class="navbar-nav">
<li class="nav-item me-3">
<a class="nav-link" asp-area="" asp-controller="Home" asp-action="Index">Главная</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
<li class="nav-item me-3">
<a class="nav-link" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</li>
<li class="nav-item d-lg-none">
<a class="nav-link text-light" asp-area="" asp-controller="Home" asp-action="Privacy">Вход в аккаунт</a>
</li>
<li class="nav-item d-none d-lg-inline">
<a class="btn btn-light" asp-area="" asp-controller="Home" asp-action="Privacy">Вход в аккаунт</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<div class="container">
<div class="container-md py-4 mb-4">
<main role="main" class="pb-3">
@RenderBody()
</main>

View File

@ -1,6 +1,10 @@
/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
for details on configuring this project to bundle and minify static web assets. */
body {
background-color: #ff0000;
}
a.navbar-brand {
white-space: normal;
text-align: center;
@ -46,3 +50,4 @@ button.accept-policy {
white-space: nowrap;
line-height: 60px;
}

View File

@ -5,5 +5,6 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
"AllowedHosts": "*",
"IPAddress": "http://localhost:5024"
}