Skip to content

Commit

Permalink
Merge pull request #3 from bentran1vn/revert-2-revert-1-Entity
Browse files Browse the repository at this point in the history
Revert "Revert "Add new entities and update EF Core migration""
  • Loading branch information
PhucNghi176 authored Sep 27, 2024
2 parents 5c23372 + 29ee2a7 commit 200c2c2
Show file tree
Hide file tree
Showing 25 changed files with 1,979 additions and 18 deletions.
4 changes: 2 additions & 2 deletions MBS-COMMAND.API/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"ConnectionStrings": {
"ConnectionStrings": "Server=14.225.205.54;Database=AntreeDB;Uid=sa;Pwd=Thientan291157@;Trust Server Certificate=True;",
"Redis": "103.162.14.116:6379"
"ConnectionStrings": "Server=103.185.184.35;Database=PRNSUPPER;Uid=sa;Pwd=AnhBiLongDaiKa@;Trust Server Certificate=True;",
"Redis": "103.185.184.35:6379,password=Thientan291157@,abortConnect=false"
},
"JwtOption": {
"Issuer": "http://103.162.14.116:8080",
Expand Down
21 changes: 21 additions & 0 deletions MBS-COMMAND.API/logs/log-20240927.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
2024-09-27 16:52:10.778 +07:00 [WRN] Sensitive data logging is enabled. Log entries and exception messages may include sensitive application data; this mode should only be enabled during development.
2024-09-27 16:52:29.724 +07:00 [WRN] Sensitive data logging is enabled. Log entries and exception messages may include sensitive application data; this mode should only be enabled during development.
2024-09-27 16:52:30.787 +07:00 [ERR] Failed executing DbCommand (43ms) [Parameters=[], CommandType='"Text"', CommandTimeout='30']
CREATE TABLE [Users] (
[Id] uniqueidentifier NOT NULL,
[Email] nvarchar(max) NOT NULL,
[FullName] nvarchar(max) NULL,
[Password] nvarchar(max) NOT NULL,
[Gender] bit NOT NULL,
[Phonenumber] nvarchar(max) NOT NULL,
[Role] int NOT NULL,
[Points] int NOT NULL,
[Status] int NOT NULL,
[MentorId] uniqueidentifier NULL,
[CreatedOnUtc] datetimeoffset NOT NULL,
[ModifiedOnUtc] datetimeoffset NULL,
[IsDeleted] bit NOT NULL,
CONSTRAINT [PK_Users] PRIMARY KEY ([Id]),
CONSTRAINT [FK_Users_Users_MentorId] FOREIGN KEY ([MentorId]) REFERENCES [Users] ([Id])
);
2024-09-27 16:53:37.481 +07:00 [WRN] Sensitive data logging is enabled. Log entries and exception messages may include sensitive application data; this mode should only be enabled during development.
7 changes: 7 additions & 0 deletions MBS_COMMAND.Domain/Abstractions/Entities/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,11 @@ public abstract class Entity<T> : IEntity<T>
public T Id { get; protected set; }

public bool IsDeleted { get; protected set; }
}
public abstract class Entity : Entity<Guid>, IEntity<Guid>
{
protected Entity()
{
Id = Guid.NewGuid();
}
}
5 changes: 1 addition & 4 deletions MBS_COMMAND.Domain/Abstractions/Entities/IEntity.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
namespace MBS_COMMAND.Domain.Abstractions.Entities;

public interface IEntity<T>
{

}
public interface IEntity<T>;
10 changes: 10 additions & 0 deletions MBS_COMMAND.Domain/Entities/Category.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using MBS_COMMAND.Domain.Abstractions.Entities;

namespace MBS_COMMAND.Domain.Entities;

public class Category : Entity<Guid>, IAuditableEntity
{
public string Name { get; set; }
public DateTimeOffset CreatedOnUtc { get; set; }
public DateTimeOffset? ModifiedOnUtc { get; set; }
}
14 changes: 14 additions & 0 deletions MBS_COMMAND.Domain/Entities/Certificate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using MBS_COMMAND.Domain.Abstractions.Entities;

namespace MBS_COMMAND.Domain.Entities;

public class Certificate : Entity<Guid>,IAuditableEntity
{
public string Name { get; set; }
public string Description { get; set; }
public string ImageUrl { get; set; }
public Guid CategoryId { get; set; }
public virtual Category? Category { get; set; }
public DateTimeOffset CreatedOnUtc { get ; set ; }
public DateTimeOffset? ModifiedOnUtc { get ; set ; }
}
10 changes: 10 additions & 0 deletions MBS_COMMAND.Domain/Entities/Config.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.ComponentModel.DataAnnotations;

namespace MBS_COMMAND.Domain.Entities;

public class Config
{
[Key]
public string Key { get; set; }
public int Value { get; set; }
}
15 changes: 15 additions & 0 deletions MBS_COMMAND.Domain/Entities/Feedback.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using MBS_COMMAND.Domain.Abstractions.Entities;

namespace MBS_COMMAND.Domain.Entities;

public class Feedback : Entity<Guid>, IAuditableEntity
{

public string? Content { get; set; }
public int Rating { get; set; }
public Guid? SlotId { get; set; }
public virtual Slot? Slot { get; set; }
public bool IsMentor { get; set; }
public DateTimeOffset CreatedOnUtc { get; set; }
public DateTimeOffset? ModifiedOnUtc { get; set; }
}
16 changes: 16 additions & 0 deletions MBS_COMMAND.Domain/Entities/Group.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using MBS_AUTHORIZATION.Domain.Entities;
using MBS_COMMAND.Domain.Abstractions.Entities;

namespace MBS_COMMAND.Domain.Entities;

public class Group : Entity<Guid>, IAuditableEntity
{
public string Name { get; set; }
public Guid? MentorId { get; set; }
public virtual User? Mentor { get; set; }
public string Stack { get; set; }
public Guid? ProjectId { get; set; }
public virtual Project? Project { get; set; }
public DateTimeOffset CreatedOnUtc { get ; set ; }
public DateTimeOffset? ModifiedOnUtc { get ; set ; }
}
11 changes: 11 additions & 0 deletions MBS_COMMAND.Domain/Entities/Group_Student_Mapping.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using MBS_AUTHORIZATION.Domain.Entities;

namespace MBS_COMMAND.Domain.Entities;

public class Group_Student_Mapping
{
public Guid GroupId { get; set; }
public virtual Group Group { get; set; }
public Guid StudentId { get; set; }
public virtual User Student { get; set; }
}
15 changes: 15 additions & 0 deletions MBS_COMMAND.Domain/Entities/Project.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using MBS_COMMAND.Domain.Abstractions.Entities;

namespace MBS_COMMAND.Domain.Entities;

public class Project : Entity<Guid>, IAuditableEntity
{
public string Name { get ; set ; }
public string Description { get ; set ; }




public DateTimeOffset CreatedOnUtc { get ; set ; }
public DateTimeOffset? ModifiedOnUtc { get ; set ; }
}
20 changes: 20 additions & 0 deletions MBS_COMMAND.Domain/Entities/Schedule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using MBS_AUTHORIZATION.Domain.Entities;
using MBS_COMMAND.Domain.Abstractions.Entities;

namespace MBS_COMMAND.Domain.Entities;

public class Schedule : Entity<Guid>, IAuditableEntity
{
public Guid MentorId { get; set; }
public virtual User? Mentor { get; set; }

public Guid GroupId { get; set; }
public virtual Group? Group { get; set; }
public TimeOnly StartTime { get; set; }
public TimeOnly EndTime { get; set; }
public DateOnly Date { get; set; }
public Guid SubjectId { get; set; }
public virtual Subject? Subject { get; set; }
public DateTimeOffset CreatedOnUtc { get ; set ; }
public DateTimeOffset? ModifiedOnUtc { get ; set ; }
}
12 changes: 12 additions & 0 deletions MBS_COMMAND.Domain/Entities/Semester.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using MBS_COMMAND.Domain.Abstractions.Entities;

namespace MBS_COMMAND.Domain.Entities;

public class Semester : Entity<Guid>, IAuditableEntity
{
public string Name { get; set; }
public DateOnly From { get; set; }
public DateOnly To { get; set; }
public DateTimeOffset CreatedOnUtc { get; set; }
public DateTimeOffset? ModifiedOnUtc { get; set; }
}
14 changes: 14 additions & 0 deletions MBS_COMMAND.Domain/Entities/Skill.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using MBS_COMMAND.Domain.Abstractions.Entities;

namespace MBS_COMMAND.Domain.Entities;

public class Skill : Entity<Guid>, IAuditableEntity
{

public Guid? CategoryId { get; set; }
public virtual Category? Category { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public DateTimeOffset CreatedOnUtc { get; set; }
public DateTimeOffset? ModifiedOnUtc { get; set; }
}
16 changes: 16 additions & 0 deletions MBS_COMMAND.Domain/Entities/Slot.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using MBS_AUTHORIZATION.Domain.Entities;
using MBS_COMMAND.Domain.Abstractions.Entities;

namespace MBS_COMMAND.Domain.Entities;

public class Slot : Entity<Guid>, IAuditableEntity
{
public Guid? MentorId { get; set; }
public virtual User? Mentor { get; set; }
public TimeOnly StartTime { get; set; }
public TimeOnly EndTime { get; set; }
public DateOnly Date { get; set; }
public int Status { get; set; }
public DateTimeOffset CreatedOnUtc { get; set; }
public DateTimeOffset? ModifiedOnUtc { get; set; }
}
20 changes: 20 additions & 0 deletions MBS_COMMAND.Domain/Entities/Subject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using MBS_COMMAND.Domain.Abstractions.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MBS_COMMAND.Domain.Entities;

public class Subject : Entity<Guid>, IAuditableEntity
{
public string Name { get ; set ; }
public int Status { get ; set ; }
public Guid SemesterId { get; set; }
public virtual Semester? Semester { get; set; }


public DateTimeOffset CreatedOnUtc { get ; set ; }
public DateTimeOffset? ModifiedOnUtc { get ; set ; }
}
17 changes: 17 additions & 0 deletions MBS_COMMAND.Domain/Entities/Transaction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using MBS_AUTHORIZATION.Domain.Entities;
using MBS_COMMAND.Domain.Abstractions.Entities;

namespace MBS_COMMAND.Domain.Entities;

public class Transaction : Entity<Guid>, IAuditableEntity
{
public Guid? UserId { get; set; }
public virtual User? User { get; set; }
public Guid? SlotId { get; set; }
public virtual Slot? Slot { get; set; }
public DateOnly Date { get; set; }
public int Status { get; set; }

public DateTimeOffset CreatedOnUtc { get; set; }
public DateTimeOffset? ModifiedOnUtc { get; set; }
}
20 changes: 20 additions & 0 deletions MBS_COMMAND.Domain/Entities/User.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using MBS_COMMAND.Domain.Abstractions.Entities;

namespace MBS_AUTHORIZATION.Domain.Entities;

public class User : Entity<Guid>, IAuditableEntity
{
public string Email { get; set; }
public string? FullName { get; set; }
public string Password { get; set; }
public bool Gender { get; set; }
public string Phonenumber { get; set; }
public int Role { get; set; }
public int Points { get; set; }
public int Status { get; set; }
public Guid? MentorId { get; set; }

public virtual User? Mentor { get; set; }
public DateTimeOffset CreatedOnUtc { get; set; }
public DateTimeOffset? ModifiedOnUtc { get; set; }
}
4 changes: 0 additions & 4 deletions MBS_COMMAND.Domain/MBS_COMMAND.Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,4 @@
<ProjectReference Include="..\MBS_COMMAND.Contract\MBS_COMMAND.Contract.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Entities\" />
</ItemGroup>

</Project>
24 changes: 17 additions & 7 deletions MBS_COMMAND.Persistence/ApplicationDbContext.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using MBS_AUTHORIZATION.Domain.Entities;
using MBS_COMMAND.Domain.Entities;
using Microsoft.EntityFrameworkCore;

namespace MBS_COMMAND.Persistence;
Expand All @@ -12,11 +14,19 @@ public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
protected override void OnModelCreating(ModelBuilder builder) =>
builder.ApplyConfigurationsFromAssembly(AssemblyReference.Assembly);

// public DbSet<AppUser> AppUses { get; set; }
// public DbSet<Action> Actions { get; set; }
// public DbSet<Function> Functions { get; set; }
// public DbSet<ActionInFunction> ActionInFunctions { get; set; }
// public DbSet<Permission> Permissions { get; set; }
//
// public DbSet<Product> Products { get; set; }
public virtual DbSet<Category> Categories { get; set; }
public virtual DbSet<Certificate> Certificates { get; set; }
public virtual DbSet<Config> Configs { get; set; }
public virtual DbSet<Feedback> Feedbacks { get; set; }
public virtual DbSet<Group> Groups { get; set; }
public virtual DbSet<Group_Student_Mapping> group_Student_Mappings { get; set; }
public virtual DbSet<Project> Projects { get; set; }
public virtual DbSet<Schedule> Schedules { get; set; }
public virtual DbSet<Semester> Semesters { get; set; }
public virtual DbSet<Skill> Skills { get; set; }
public virtual DbSet<Slot> Slots { get; set; }
public virtual DbSet<Subject> Subjects { get; set; }
public virtual DbSet<Transaction> Transactions { get; set; }
public virtual DbSet<User> Users { get; set; }

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using MBS_COMMAND.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MBS_COMMAND.Persistence.Configurations;

public class Group_Student_MappingConfiguration : IEntityTypeConfiguration<Group_Student_Mapping>
{
public void Configure(EntityTypeBuilder<Group_Student_Mapping> builder)
{
builder.HasKey(x => new { x.GroupId, x.StudentId });
}
}
16 changes: 15 additions & 1 deletion MBS_COMMAND.Persistence/Constants/TableNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,19 @@ internal static class TableNames
internal const string OutboxMessages = nameof(OutboxMessages);

// *********** Singular Nouns ***********
internal const string Product = nameof(Product);
internal const string Category = nameof(Category);
internal const string Certificate = nameof(Certificate);
internal const string Config = nameof(Config);
internal const string Feedback = nameof(Feedback);
internal const string Group = nameof(Group);
internal const string Group_Student_Mapping = nameof(Group_Student_Mapping);
internal const string Project = nameof(Project);
internal const string Schedule = nameof(Schedule);
internal const string Semester = nameof(Semester);
internal const string Skill = nameof(Skill);
internal const string Slot = nameof(Slot);
internal const string Subject = nameof(Subject);
internal const string Transaction = nameof(Transaction);
internal const string User = nameof(User);

}
Loading

0 comments on commit 200c2c2

Please sign in to comment.