попытки фиксить регистрацию

This commit is contained in:
Николай 2023-05-15 18:59:57 +04:00 committed by dasha
parent b984fdfb05
commit cade6df340
5 changed files with 15 additions and 6 deletions

View File

@ -10,7 +10,7 @@ namespace HardwareShopDatabaseImplement
{ {
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{ {
optionsBuilder.UseNpgsql("Host=localhost;Port=5433;Database=Computer_Hardware_Store;Username=user;Password=12345"); optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=Computer_Hardware_Store;Username=postgres;Password=1234");
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
} }

View File

@ -35,7 +35,7 @@ builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer(); builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(c => builder.Services.AddSwaggerGen(c =>
{ {
c.SwaggerDoc("v1", new OpenApiInfo { Title = "SushiBarRestApi", Version = "v1" }); c.SwaggerDoc("v1", new OpenApiInfo { Title = "HardwareShopRestApi", Version = "v1" });
}); });
var app = builder.Build(); var app = builder.Build();

View File

@ -22,13 +22,21 @@ namespace HardwareShopWorkerApp.Controllers
} }
[HttpPost] [HttpPost]
public void Register(string login, string email, string password, int role) public void Register(string login, string email, string password)
{ {
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password) || role <= 0) if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
{ {
throw new Exception("Введите логин, email, пароль и роль"); throw new Exception("Введите логин, email, пароль");
} }
APIClient.PostRequest("api/client/register", new UserBindingModel
{
Login = login,
Email = email,
Password = password,
Role = UserRole.Работник,
});
Response.Redirect("Enter"); Response.Redirect("Enter");
return;
} }
public IActionResult Index() public IActionResult Index()

View File

@ -23,6 +23,7 @@
<ProjectReference Include="..\HardwareShopBusinessLogic\HardwareShopBusinessLogic.csproj" /> <ProjectReference Include="..\HardwareShopBusinessLogic\HardwareShopBusinessLogic.csproj" />
<ProjectReference Include="..\HardwareShopContracts\HardwareShopContracts.csproj" /> <ProjectReference Include="..\HardwareShopContracts\HardwareShopContracts.csproj" />
<ProjectReference Include="..\HardwareShopDatabaseImplement\HardwareShopDatabaseImplement.csproj" /> <ProjectReference Include="..\HardwareShopDatabaseImplement\HardwareShopDatabaseImplement.csproj" />
<ProjectReference Include="..\HardwareShopDataModels\HardwareShopDataModels.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -7,5 +7,5 @@
}, },
"AllowedHosts": "*", "AllowedHosts": "*",
"IPAddress": "http://localhost:5008/" "IPAddress": "http://localhost:5254/"
} }