feat: added DAL
This commit is contained in:
11
JOBot.Backend/DAL/Context/AppDbContext.cs
Normal file
11
JOBot.Backend/DAL/Context/AppDbContext.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace JOBot.Backend.DAL.Context;
|
||||
|
||||
using JOBot.Backend.DAL.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
class AppDbContext : DbContext
|
||||
{
|
||||
public DbSet<User> Users { get; set; }
|
||||
|
||||
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
|
||||
}
|
||||
9
JOBot.Backend/DAL/Models/User.cs
Normal file
9
JOBot.Backend/DAL/Models/User.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace JOBot.Backend.DAL.Models;
|
||||
|
||||
public class User
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public long TelegramId { get; set; }
|
||||
public string? Username { get; set; }
|
||||
public DateTime CreatedAt { get; set; } = DateTime.Now;
|
||||
}
|
||||
@@ -21,7 +21,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Protobuf Include="..\Contracts\Proto\*" GrpcServices="Server"></Protobuf>
|
||||
<Protobuf Include="..\Proto\*" GrpcServices="Server"></Protobuf>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -1,6 +1,13 @@
|
||||
using JOBot.Backend.DAL.Context;
|
||||
using JOBot.Backend.Services.gRPC;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services.AddGrpc();
|
||||
builder.Services.AddDbContext<AppDbContext>(options =>
|
||||
options.UseNpgsql(builder.Configuration.GetConnectionString("PostgreSQL")));
|
||||
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
namespace JOBot.Backend.Services.gRPC;
|
||||
|
||||
using Grpc.Core;
|
||||
using JOBot.Proto;
|
||||
|
||||
@@ -8,6 +10,7 @@ class UserService : User.UserBase
|
||||
ServerCallContext context)
|
||||
|
||||
{
|
||||
|
||||
return Task.FromResult(new RegisterResponse
|
||||
{
|
||||
UserId = request.UserId
|
||||
|
||||
@@ -5,5 +5,8 @@
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
"AllowedHosts": "*",
|
||||
"ConnectionStrings": {
|
||||
"PostgreSQL": "Host=localhost;Port=5432;Database=jobot;Username=postgres;Password=LocalDbPass"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user