fixed compile errors
This commit is contained in:
parent
5701c9e43e
commit
c01db4a04b
|
|
@ -0,0 +1,13 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ProjectGrid.Models;
|
||||
|
||||
|
||||
namespace ProjectGrid.Data
|
||||
{
|
||||
public partial class DataAccessContext : DbContext
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ProjectGrid.Models;
|
||||
|
||||
|
||||
namespace ProjectGrid.Data
|
||||
{
|
||||
public partial class DataAccessContext : DbContext, IUserRepository
|
||||
{
|
||||
public DbSet<UserData> Users { get; set; }
|
||||
|
||||
public IEnumerable<UserModel> GetAll()
|
||||
{
|
||||
return Users.Select<UserData, UserModel>(data => data.ToModel());
|
||||
}
|
||||
public UserModel Add(UserModel user)
|
||||
{
|
||||
// TODO: check if exist
|
||||
Users.Add(new UserData(user));
|
||||
SaveChanges();
|
||||
return user;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -7,28 +7,14 @@ using ProjectGrid.Models;
|
|||
|
||||
namespace ProjectGrid.Data
|
||||
{
|
||||
public class DataAccessContext : DbContext, IUserRepository
|
||||
public partial class DataAccessContext : DbContext, IUserRepository
|
||||
{
|
||||
public DataAccessContext(DbContextOptions<DataAccessContext> options) : base(options) { }
|
||||
|
||||
public DbSet<UserData> Users { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<UserData>().ToTable("USER");
|
||||
}
|
||||
|
||||
public IEnumerable<UserModel> GetAll()
|
||||
{
|
||||
return Users.Select<UserData, UserModel>(data => data.ToModel());
|
||||
}
|
||||
|
||||
public UserModel Add(UserModel user)
|
||||
{
|
||||
// TODO: check if exist
|
||||
Users.Add(new UserData(user));
|
||||
SaveChanges();
|
||||
return user;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,19 @@
|
|||
using ProjectGrid.Models;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
|
||||
namespace ProjectGrid.Data
|
||||
{
|
||||
[Table("Map", Schema = "Map")]
|
||||
public class MapData
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
[Required]
|
||||
public uint Width { get; set; }
|
||||
[Required]
|
||||
public uint Height { get; set; }
|
||||
|
||||
public MapData() { }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue