Added User with ability to login and register. By default, user is not an admin. DTO expects an integer and will convert to Boolean.

This commit is contained in:
Joseph Milazzo 2020-12-13 16:07:25 -06:00
parent 2b521924d0
commit 5da41ea6f3
12 changed files with 239 additions and 10 deletions

View file

@ -2,8 +2,11 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using API.Data;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
@ -11,9 +14,26 @@ namespace API
{
public class Program
{
public static void Main(string[] args)
public static async Task Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
var host = CreateHostBuilder(args).Build();
using var scope = host.Services.CreateScope();
var services = scope.ServiceProvider;
try
{
var context = services.GetRequiredService<DataContext>();
// Apply all migrations on startup
await context.Database.MigrateAsync();
}
catch (Exception ex)
{
var logger = services.GetRequiredService < ILogger<Program>>();
logger.LogError(ex, "An error occurred during migration");
}
await host.RunAsync();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>