Changed the LastLogin property of the User model to allow null values, explcitly change the Entity User context to create a User table, and resolved bug that caused build issues in the SongController API class. The bug was caused by forgetting to change the type of the method after switching it from ActionResult to IActionResult. #40
This commit is contained in:
@@ -45,7 +45,7 @@ namespace Icarus.Controllers
|
||||
|
||||
[HttpGet]
|
||||
[Authorize("read:song_details")]
|
||||
public IActionResult<IEnumerable<Song>> Get()
|
||||
public IActionResult Get()
|
||||
{
|
||||
List<Song> songs = new List<Song>();
|
||||
Console.WriteLine("Attemtping to retrieve songs");
|
||||
@@ -68,7 +68,7 @@ namespace Icarus.Controllers
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
public IActionResult<Song> Get(int id)
|
||||
public IActionResult Get(int id)
|
||||
{
|
||||
MusicStoreContext context = HttpContext
|
||||
.RequestServices
|
||||
|
||||
@@ -10,18 +10,23 @@ using Icarus.Models;
|
||||
|
||||
namespace Icarus.Models.Context
|
||||
{
|
||||
public class UserContext : DbContext
|
||||
{
|
||||
public DbSet<User> Users { get; set; }
|
||||
public class UserContext : DbContext
|
||||
{
|
||||
public DbSet<User> Users { get; set; }
|
||||
|
||||
|
||||
public UserContext(DbContextOptions<UserContext> options)
|
||||
: base(options)
|
||||
{ }
|
||||
: base(options)
|
||||
{ }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<User>();
|
||||
}
|
||||
}
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<User>()
|
||||
.ToTable("User");
|
||||
modelBuilder.Entity<User>()
|
||||
.Property(u => u.LastLogin).IsRequired(false);
|
||||
modelBuilder.Entity<User>()
|
||||
.Property(u => u.DateCreated).HasDefaultValue(DateTime.Now);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -27,6 +27,6 @@ namespace Icarus.Models
|
||||
[JsonProperty("date_created")]
|
||||
public DateTime DateCreated { get; set; }
|
||||
[JsonProperty("last_login")]
|
||||
public DateTime LastLogin { get; set; }
|
||||
public DateTime? LastLogin { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user