Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Project.App/Project.Api/Controllers/ExampleController.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore.Metadata;
using Project.Api.Models;
using Project.Api.Repositories;
using Project.Api.Services;
using Project.DTOs;
// using Project.Models;
using Project.Repositories;
using Project.Services;
using Serilog;

namespace Project.Controllers
namespace Project.Api.Controllers
{
public class ExampleController : ControllerBase
{
Expand Down
5 changes: 4 additions & 1 deletion Project.App/Project.Api/Data/AppDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public AppDbContext(DbContextOptions<AppDbContext> options)
public DbSet<Room> Rooms { get; set; }
public DbSet<RoomPlayer> RoomPlayers { get; set; }
public DbSet<Hand> Hands { get; set; }


/// <summary>
/// Provides the configuration for TradeHubContext models.
Expand All @@ -23,6 +22,10 @@ public AppDbContext(DbContextOptions<AppDbContext> options)
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);

// Configure GameState as JSON column for SQL Server
modelBuilder.Entity<Room>().Property(r => r.GameState).HasColumnType("nvarchar(max)");

OnModelCreatingPartial(modelBuilder);
}

Expand Down
4 changes: 2 additions & 2 deletions Project.App/Project.Api/Data/MappingProfile.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Net.Http.Headers;
using AutoMapper;
using Project.DTOs;
using Project.Api.Models;
using Project.DTOs;

namespace Project.Data
namespace Project.Api.Data
{
public class MappingProfile : Profile
{
Expand Down
2 changes: 1 addition & 1 deletion Project.App/Project.Api/Models/Hand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class Hand
[Key]
public long Id { get; set; }

public int RoomPlayerId { get; set; }
public long RoomPlayerId { get; set; }

public int Order { get; set; }

Expand Down
39 changes: 35 additions & 4 deletions Project.App/Project.Api/Models/Room.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,45 @@
namespace Project.Api.Models;

using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

public class Room
{
[Key] public Guid Id {get; set;}
[Key]
public Guid Id { get; set; }

public Guid HostId { get; set; }

public bool isPublic { get; set; }

public bool isActive { get; set; }

public DateTime CreatedAt { get; set; }

public DateTime? StartedAt { get; set; }

public DateTime? EndedAt { get; set; }

[MaxLength(50)]
public required string GameMode { get; set; }

public required string GameState { get; set; }

[MaxLength(500)]
public string? Description { get; set; }

public int MaxPlayers { get; set; }

public int MinPlayers { get; set; }

public long HostId {get;set;}
public User Host { get; set; } = null!;
public int DeckId { get; set; }

public int Round { get; set; }

public string State { get; set; } = string.Empty;

[ForeignKey("HostId")]
public virtual User? Host { get; set; }

}
public virtual ICollection<RoomPlayer> RoomPlayers { get; set; } = [];
}
51 changes: 26 additions & 25 deletions Project.App/Project.Api/Models/RoomPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,32 @@
using System.Numerics;
using Project.Api.Enum;

namespace Project.Api.Models
namespace Project.Api.Models;

public class RoomPlayer
{
public class RoomPlayer
{
[Key]
public int Id { get; set; }


[Required]
public Guid RoomId { get; set; }
// Navigation property for Room
[ForeignKey("RoomId")]
public Room? Room { get; set; }

[Required]
public long UserId { get; set; }
// Navigation property for User
[ForeignKey("UserId")]
public User? User { get; set; }

public Role Role { get; set; }

public Status Status { get; set; }
[Required]
public BigInteger Balance { get; set; }
}
[Key]
public long Id { get; set; }

[Required]
public Guid RoomId { get; set; }

[Required]
public int UserId { get; set; }

[ForeignKey("RoomId")]
public virtual Room? Room { get; set; }

[ForeignKey("UserId")]
public virtual User? User { get; set; }

public virtual ICollection<Hand> Hands { get; set; } = [];

public Role Role { get; set; }

public Status Status { get; set; }
[Required]
public long Balance { get; set; }


}
12 changes: 7 additions & 5 deletions Project.App/Project.Api/Models/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ namespace Project.Api.Models
public class User
{
[Key]
public int Id {get; set;}
public int Id { get; set; }

[Required, MaxLength(256)]
public string Name { get; set;} = null!;
public string Name { get; set; } = null!;

[Required, MaxLength(256)]
public string Email {get; set;} = null!;
public string Email { get; set; } = null!;

[Required, MaxLength(256)]
public string PasswordHash {get; set;} = null!;
public string PasswordHash { get; set; } = null!;
public double Balance { get; set; } = 1000;

public ICollection<RoomPlayer> RoomPlayers { get; set; } = new List<RoomPlayer>();

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Project.Api.Models;

namespace Project.Repositories
namespace Project.Api.Repositories
{
public interface IRepositoryExample { }
}
4 changes: 2 additions & 2 deletions Project.App/Project.Api/Repositories/RepositoryExample.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Microsoft.EntityFrameworkCore;
using Project.Data;
using Project.Api.Data;
using Project.Api.Models;

namespace Project.Api.Repositories
{
public class IRepositoryExample { }
public class RepositoryExample : IRepositoryExample { }
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Project.Api.Models;

namespace Project.Services
namespace Project.Api.Services
{
public interface IServiceExample { }
}
Loading