File tree Expand file tree Collapse file tree
Eventz.Infrastructure/Configurations Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,11 +16,13 @@ public class Event
1616 public DateTime EndDate { get ; set ; }
1717 public int Capacity { get ; set ; }
1818 public bool IsPublic { get ; set ; }
19- public string OrganizerId { get ; set ; }
19+ // public string OrganizerId { get; set; }
2020 public int VenueId { get ; set ; }
2121 public int CategoryId { get ; set ; }
22- public Venue venue { get ; set ; }
23- public Category category { get ; set ; }
22+ public Venue Venue { get ; set ; }
23+ public Category Category { get ; set ; }
24+
25+ //public User Organizer { get; set; }
2426
2527 public ICollection < EventRegistration > Registrations { get ; set ; }
2628 public ICollection < Ticket > Tickets { get ; set ; }
Original file line number Diff line number Diff line change @@ -10,11 +10,12 @@ public class EventRegistration
1010 {
1111 public int Id { get ; set ; }
1212 public Guid EventRegistrationToken { get ; set ; } = Guid . NewGuid ( ) ;
13- public string UserId { get ; set ; }
14- public string EventId { get ; set ; }
13+ public int UserId { get ; set ; }
14+ public int EventId { get ; set ; }
1515 public DateTime RegisteredAt { get ; set ; }
1616 public bool CheckedIn { get ; set ; }
1717 public Event Event { get ; set ; }
18+ public User User { get ; set ; }
1819
1920 }
2021}
Original file line number Diff line number Diff line change @@ -9,12 +9,11 @@ namespace Eventz.Domain.Entitites
99 public class User
1010 {
1111 public int Id { get ; set ; }
12- public Guid UserToken { get ; set ; } = new Guid ( ) ;
12+ public Guid UserToken { get ; set ; } = Guid . NewGuid ( ) ;
1313 public string UserName { get ; set ; }
1414 public string Email { get ; set ; }
1515 public string Password { get ; set ; }
1616 public DateTime CreatedAt { get ; set ; }
17- public List < Ticket > Tickets { get ; set ; }
18- public List < Event > Events { get ; set ; }
17+ public List < EventRegistration > EventRegistrations { get ; set ; } = new List < EventRegistration > ( ) ;
1918 }
2019}
Original file line number Diff line number Diff line change 1+ using Eventz . Domain . Entitites ;
2+ using Microsoft . EntityFrameworkCore ;
3+ using Microsoft . EntityFrameworkCore . Metadata . Builders ;
4+
5+ namespace Eventz . Infrastructure . Configurations
6+ {
7+ public class CategoryConfiguration : IEntityTypeConfiguration < Category >
8+ {
9+ public void Configure ( EntityTypeBuilder < Category > builder )
10+ {
11+ builder . ToTable ( "Categories" ) ;
12+ builder . HasKey ( x => x . Id ) ;
13+ }
14+
15+ }
16+ }
Original file line number Diff line number Diff line change 1+ using Eventz . Domain . Entitites ;
2+ using Microsoft . EntityFrameworkCore ;
3+ using Microsoft . EntityFrameworkCore . Metadata . Builders ;
4+ using System ;
5+ using System . Collections . Generic ;
6+ using System . Linq ;
7+ using System . Text ;
8+ using System . Threading . Tasks ;
9+
10+ namespace Eventz . Infrastructure . Configurations
11+ {
12+ public class EventConfiguration : IEntityTypeConfiguration < Event >
13+ {
14+ public void Configure ( EntityTypeBuilder < Event > builder )
15+ {
16+ builder . ToTable ( "Events" ) ;
17+ builder . HasKey ( e => e . Id ) ;
18+ builder . Property ( e => e . Name )
19+ . IsRequired ( )
20+ . HasMaxLength ( 256 ) ;
21+ builder . Property ( e => e . Description )
22+ . IsRequired ( )
23+ . HasMaxLength ( 256 ) ;
24+ builder . Property ( e => e . StartDate ) . IsRequired ( ) ;
25+ builder . Property ( e => e . EndDate )
26+ . IsRequired ( ) ;
27+
28+ //relations
29+ builder . HasOne ( e => e . Venue )
30+ . WithMany ( v => v . Events )
31+ . HasForeignKey ( e => e . VenueId )
32+ . OnDelete ( DeleteBehavior . Restrict ) ;
33+
34+ builder . HasOne ( e => e . Category )
35+ . WithMany ( v => v . Events )
36+ . HasForeignKey ( e => e . CategoryId )
37+ . OnDelete ( DeleteBehavior . Restrict ) ;
38+ }
39+ }
40+ }
Original file line number Diff line number Diff line change 1+ using Eventz . Domain . Entitites ;
2+ using Microsoft . EntityFrameworkCore ;
3+ using Microsoft . EntityFrameworkCore . Metadata . Builders ;
4+ using System ;
5+ using System . Collections . Generic ;
6+ using System . Linq ;
7+ using System . Text ;
8+ using System . Threading . Tasks ;
9+
10+ namespace Eventz . Infrastructure . Configurations
11+ {
12+ public class EventRegistrationConfiguration : IEntityTypeConfiguration < EventRegistration >
13+ {
14+ public void Configure ( EntityTypeBuilder < EventRegistration > builder )
15+ {
16+ builder . HasKey ( er => er . Id ) ;
17+ builder . HasIndex ( er => new { er . UserId , er . EventId } ) . IsUnique ( ) ;
18+ builder . Property ( er => er . RegisteredAt )
19+ . HasDefaultValueSql ( "GETUTCDATE()" ) ;
20+
21+ builder . HasOne ( er => er . Event )
22+ . WithMany ( e => e . Registrations )
23+ . HasForeignKey ( e => e . EventId )
24+ . OnDelete ( DeleteBehavior . Cascade ) ;
25+
26+ builder . HasOne ( er => er . User )
27+ . WithMany ( u => u . EventRegistrations )
28+ . HasForeignKey ( e => e . UserId )
29+ . OnDelete ( DeleteBehavior . Cascade ) ;
30+ }
31+ }
32+
33+ }
Original file line number Diff line number Diff line change 1+ using Eventz . Domain . Entitites ;
2+ using Microsoft . EntityFrameworkCore ;
3+ using Microsoft . EntityFrameworkCore . Metadata . Builders ;
4+ using System ;
5+ using System . Collections . Generic ;
6+ using System . Linq ;
7+ using System . Text ;
8+ using System . Threading . Tasks ;
9+
10+ namespace Eventz . Infrastructure . Configurations
11+ {
12+ public class TicketConfiguration : IEntityTypeConfiguration < Ticket >
13+ {
14+ public void Configure ( EntityTypeBuilder < Ticket > builder )
15+ {
16+ builder . ToTable ( "Tickets" ) ;
17+ builder . HasKey ( t => t . Id ) ;
18+ builder . HasOne ( t => t . Event )
19+ . WithMany ( e => e . Tickets )
20+ . HasForeignKey ( t => t . EventId )
21+ . OnDelete ( DeleteBehavior . Cascade ) ;
22+ }
23+ }
24+ }
Original file line number Diff line number Diff line change 1- using Eventz . Domain . Entitites ;
1+ using Eventz . Domain . Entitites ;
22using Microsoft . EntityFrameworkCore ;
33using Microsoft . EntityFrameworkCore . Metadata . Builders ;
4- using System ;
5- using System . Collections . Generic ;
6- using System . Linq ;
7- using System . Text ;
8- using System . Threading . Tasks ;
94
105namespace Eventz . Infrastructure . Configurations
116{
@@ -15,10 +10,10 @@ public void Configure (EntityTypeBuilder<User> builder)
1510 {
1611 builder . ToTable ( "Users" ) ;
1712
18- builder . HasKey ( x => x . Id ) ;
19- builder . HasMany ( u => u . Events ) ;
20- builder . HasMany ( u => u . Tickets ) ;
13+ builder . HasKey ( u => u . Id ) ;
2114 builder . HasIndex ( u => u . Email ) . IsUnique ( ) ;
15+ builder . Property ( u => u . CreatedAt ) . HasDefaultValueSql ( "GETUTCDATE()" ) ;
16+
2217 }
2318
2419 }
Original file line number Diff line number Diff line change 1+ using Eventz . Domain . Entitites ;
2+ using Microsoft . EntityFrameworkCore ;
3+ using Microsoft . EntityFrameworkCore . Metadata . Builders ;
4+ using System ;
5+ using System . Collections . Generic ;
6+ using System . Linq ;
7+ using System . Text ;
8+ using System . Threading . Tasks ;
9+
10+ namespace Eventz . Infrastructure . Configurations
11+ {
12+ public class VenueConfiguration : IEntityTypeConfiguration < Venue >
13+ {
14+ public void Configure ( EntityTypeBuilder < Venue > builder )
15+ {
16+ builder . ToTable ( "Venues" ) ;
17+ builder . HasIndex ( v => v . Id ) ;
18+ builder . HasMany ( v => v . Events )
19+ . WithOne ( e => e . Venue )
20+ . HasForeignKey ( e => e . VenueId )
21+ . OnDelete ( DeleteBehavior . Restrict ) ;
22+ }
23+ }
24+ }
You can’t perform that action at this time.
0 commit comments