Yuyuqt commited on
Commit
1e653a4
·
1 Parent(s): ccc2569

add: clean out

Browse files
DbConnect/Data/AppDbContext.cs CHANGED
@@ -1,4 +1,4 @@
1
- using System;
2
  using System.Collections.Generic;
3
  using DbConnect.Entities;
4
  using Microsoft.EntityFrameworkCore;
@@ -7,10 +7,6 @@ namespace DbConnect.Data;
7
 
8
  public partial class AppDbContext : DbContext
9
  {
10
- public AppDbContext()
11
- {
12
- }
13
-
14
  public AppDbContext(DbContextOptions<AppDbContext> options)
15
  : base(options)
16
  {
@@ -24,15 +20,14 @@ public partial class AppDbContext : DbContext
24
 
25
  public virtual DbSet<Membership> Memberships { get; set; }
26
 
 
 
27
  public virtual DbSet<User> Users { get; set; }
28
 
29
  public virtual DbSet<UserSubscription> UserSubscriptions { get; set; }
30
 
31
- public virtual DbSet<Notification> Notifications { get; set; }
32
-
33
  public virtual DbSet<WishlistItem> WishlistItems { get; set; }
34
 
35
-
36
  protected override void OnModelCreating(ModelBuilder modelBuilder)
37
  {
38
  modelBuilder.Entity<Book>(entity =>
@@ -117,6 +112,26 @@ public partial class AppDbContext : DbContext
117
  entity.Property(e => e.Type).HasMaxLength(50);
118
  });
119
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  modelBuilder.Entity<User>(entity =>
121
  {
122
  entity.HasIndex(e => e.Email, "UQ_Users_Email").IsUnique();
@@ -127,6 +142,7 @@ public partial class AppDbContext : DbContext
127
  .HasDefaultValueSql("(getdate())")
128
  .HasColumnType("datetime");
129
  entity.Property(e => e.Email).HasMaxLength(100);
 
130
  entity.Property(e => e.FullName).HasMaxLength(100);
131
  entity.Property(e => e.IsActive).HasDefaultValue(true);
132
  entity.Property(e => e.PhoneNumber).HasMaxLength(20);
@@ -136,7 +152,6 @@ public partial class AppDbContext : DbContext
136
  entity.Property(e => e.StudentId).HasMaxLength(20);
137
  entity.Property(e => e.SuspensionEndDate).HasColumnType("datetime");
138
  entity.Property(e => e.UpdatedAt).HasColumnType("datetime");
139
- entity.Property(e => e.FcmToken).HasMaxLength(500);
140
  });
141
 
142
  modelBuilder.Entity<UserSubscription>(entity =>
@@ -161,42 +176,22 @@ public partial class AppDbContext : DbContext
161
  .HasConstraintName("FK_UserSubscriptions_Users");
162
  });
163
 
164
- modelBuilder.Entity<Notification>(entity =>
165
- {
166
- entity.HasKey(e => e.Id);
167
-
168
- entity.Property(e => e.Title).HasMaxLength(200);
169
- entity.Property(e => e.Message).HasMaxLength(1000);
170
- entity.Property(e => e.Type).HasMaxLength(50).HasDefaultValue("Info");
171
- entity.Property(e => e.ActionLink).HasMaxLength(500);
172
- entity.Property(e => e.ActionText).HasMaxLength(100);
173
- entity.Property(e => e.IsRead).HasDefaultValue(false);
174
- entity.Property(e => e.CreatedAt)
175
- .HasDefaultValueSql("(getdate())")
176
- .HasColumnType("datetime");
177
-
178
- entity.HasOne(d => d.User).WithMany()
179
- .HasForeignKey(d => d.UserId)
180
- .OnDelete(DeleteBehavior.Cascade)
181
- .HasConstraintName("FK_Notifications_Users");
182
- });
183
-
184
  modelBuilder.Entity<WishlistItem>(entity =>
185
  {
186
- entity.HasKey(e => e.Id);
 
 
187
 
188
  entity.Property(e => e.AddedAt)
189
  .HasDefaultValueSql("(getdate())")
190
  .HasColumnType("datetime");
191
 
192
- entity.HasOne(d => d.Book).WithMany()
193
  .HasForeignKey(d => d.BookId)
194
- .OnDelete(DeleteBehavior.Cascade)
195
  .HasConstraintName("FK_WishlistItems_Books");
196
 
197
- entity.HasOne(d => d.User).WithMany()
198
  .HasForeignKey(d => d.UserId)
199
- .OnDelete(DeleteBehavior.Cascade)
200
  .HasConstraintName("FK_WishlistItems_Users");
201
  });
202
 
 
1
+ using System;
2
  using System.Collections.Generic;
3
  using DbConnect.Entities;
4
  using Microsoft.EntityFrameworkCore;
 
7
 
8
  public partial class AppDbContext : DbContext
9
  {
 
 
 
 
10
  public AppDbContext(DbContextOptions<AppDbContext> options)
11
  : base(options)
12
  {
 
20
 
21
  public virtual DbSet<Membership> Memberships { get; set; }
22
 
23
+ public virtual DbSet<Notification> Notifications { get; set; }
24
+
25
  public virtual DbSet<User> Users { get; set; }
26
 
27
  public virtual DbSet<UserSubscription> UserSubscriptions { get; set; }
28
 
 
 
29
  public virtual DbSet<WishlistItem> WishlistItems { get; set; }
30
 
 
31
  protected override void OnModelCreating(ModelBuilder modelBuilder)
32
  {
33
  modelBuilder.Entity<Book>(entity =>
 
112
  entity.Property(e => e.Type).HasMaxLength(50);
113
  });
114
 
115
+ modelBuilder.Entity<Notification>(entity =>
116
+ {
117
+ entity.HasIndex(e => e.UserId, "IX_Notifications_UserId");
118
+
119
+ entity.Property(e => e.ActionLink).HasMaxLength(500);
120
+ entity.Property(e => e.ActionText).HasMaxLength(100);
121
+ entity.Property(e => e.CreatedAt)
122
+ .HasDefaultValueSql("(getdate())")
123
+ .HasColumnType("datetime");
124
+ entity.Property(e => e.Message).HasMaxLength(1000);
125
+ entity.Property(e => e.Title).HasMaxLength(200);
126
+ entity.Property(e => e.Type)
127
+ .HasMaxLength(50)
128
+ .HasDefaultValue("Info");
129
+
130
+ entity.HasOne(d => d.User).WithMany(p => p.Notifications)
131
+ .HasForeignKey(d => d.UserId)
132
+ .HasConstraintName("FK_Notifications_Users");
133
+ });
134
+
135
  modelBuilder.Entity<User>(entity =>
136
  {
137
  entity.HasIndex(e => e.Email, "UQ_Users_Email").IsUnique();
 
142
  .HasDefaultValueSql("(getdate())")
143
  .HasColumnType("datetime");
144
  entity.Property(e => e.Email).HasMaxLength(100);
145
+ entity.Property(e => e.FcmToken).HasMaxLength(500);
146
  entity.Property(e => e.FullName).HasMaxLength(100);
147
  entity.Property(e => e.IsActive).HasDefaultValue(true);
148
  entity.Property(e => e.PhoneNumber).HasMaxLength(20);
 
152
  entity.Property(e => e.StudentId).HasMaxLength(20);
153
  entity.Property(e => e.SuspensionEndDate).HasColumnType("datetime");
154
  entity.Property(e => e.UpdatedAt).HasColumnType("datetime");
 
155
  });
156
 
157
  modelBuilder.Entity<UserSubscription>(entity =>
 
176
  .HasConstraintName("FK_UserSubscriptions_Users");
177
  });
178
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  modelBuilder.Entity<WishlistItem>(entity =>
180
  {
181
+ entity.HasIndex(e => e.BookId, "IX_WishlistItems_BookId");
182
+
183
+ entity.HasIndex(e => e.UserId, "IX_WishlistItems_UserId");
184
 
185
  entity.Property(e => e.AddedAt)
186
  .HasDefaultValueSql("(getdate())")
187
  .HasColumnType("datetime");
188
 
189
+ entity.HasOne(d => d.Book).WithMany(p => p.WishlistItems)
190
  .HasForeignKey(d => d.BookId)
 
191
  .HasConstraintName("FK_WishlistItems_Books");
192
 
193
+ entity.HasOne(d => d.User).WithMany(p => p.WishlistItems)
194
  .HasForeignKey(d => d.UserId)
 
195
  .HasConstraintName("FK_WishlistItems_Users");
196
  });
197
 
DbConnect/Entities/Book.cs CHANGED
@@ -31,5 +31,7 @@ public partial class Book
31
 
32
  public virtual ICollection<Borrowing> Borrowings { get; set; } = new List<Borrowing>();
33
 
 
 
34
  public virtual ICollection<Category> Categories { get; set; } = new List<Category>();
35
  }
 
31
 
32
  public virtual ICollection<Borrowing> Borrowings { get; set; } = new List<Borrowing>();
33
 
34
+ public virtual ICollection<WishlistItem> WishlistItems { get; set; } = new List<WishlistItem>();
35
+
36
  public virtual ICollection<Category> Categories { get; set; } = new List<Category>();
37
  }
DbConnect/Entities/Notification.cs CHANGED
@@ -1,4 +1,5 @@
1
- using System;
 
2
 
3
  namespace DbConnect.Entities;
4
 
@@ -12,7 +13,7 @@ public partial class Notification
12
 
13
  public string Message { get; set; } = null!;
14
 
15
- public string Type { get; set; } = "Info";
16
 
17
  public string? ActionLink { get; set; }
18
 
 
1
+ using System;
2
+ using System.Collections.Generic;
3
 
4
  namespace DbConnect.Entities;
5
 
 
13
 
14
  public string Message { get; set; } = null!;
15
 
16
+ public string Type { get; set; } = null!;
17
 
18
  public string? ActionLink { get; set; }
19
 
DbConnect/Entities/User.cs CHANGED
@@ -1,4 +1,4 @@
1
- using System;
2
  using System.Collections.Generic;
3
 
4
  namespace DbConnect.Entities;
@@ -35,5 +35,9 @@ public partial class User
35
 
36
  public virtual ICollection<Borrowing> Borrowings { get; set; } = new List<Borrowing>();
37
 
 
 
38
  public virtual ICollection<UserSubscription> UserSubscriptions { get; set; } = new List<UserSubscription>();
 
 
39
  }
 
1
+ using System;
2
  using System.Collections.Generic;
3
 
4
  namespace DbConnect.Entities;
 
35
 
36
  public virtual ICollection<Borrowing> Borrowings { get; set; } = new List<Borrowing>();
37
 
38
+ public virtual ICollection<Notification> Notifications { get; set; } = new List<Notification>();
39
+
40
  public virtual ICollection<UserSubscription> UserSubscriptions { get; set; } = new List<UserSubscription>();
41
+
42
+ public virtual ICollection<WishlistItem> WishlistItems { get; set; } = new List<WishlistItem>();
43
  }
DbConnect/Entities/WishlistItem.cs CHANGED
@@ -1,4 +1,5 @@
1
- using System;
 
2
 
3
  namespace DbConnect.Entities;
4
 
 
1
+ using System;
2
+ using System.Collections.Generic;
3
 
4
  namespace DbConnect.Entities;
5
 
DbConnect/Migrations/20260427043736_AddNotifications.Designer.cs DELETED
@@ -1,469 +0,0 @@
1
- // <auto-generated />
2
- using System;
3
- using DbConnect.Data;
4
- using Microsoft.EntityFrameworkCore;
5
- using Microsoft.EntityFrameworkCore.Infrastructure;
6
- using Microsoft.EntityFrameworkCore.Metadata;
7
- using Microsoft.EntityFrameworkCore.Migrations;
8
- using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
9
-
10
- #nullable disable
11
-
12
- namespace DbConnect.Migrations
13
- {
14
- [DbContext(typeof(AppDbContext))]
15
- [Migration("20260427043736_AddNotifications")]
16
- partial class AddNotifications
17
- {
18
- /// <inheritdoc />
19
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
20
- {
21
- #pragma warning disable 612, 618
22
- modelBuilder
23
- .HasAnnotation("ProductVersion", "9.0.0")
24
- .HasAnnotation("Relational:MaxIdentifierLength", 128);
25
-
26
- SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
27
-
28
- modelBuilder.Entity("BookCategory", b =>
29
- {
30
- b.Property<int>("BookId")
31
- .HasColumnType("int");
32
-
33
- b.Property<int>("CategoryId")
34
- .HasColumnType("int");
35
-
36
- b.HasKey("BookId", "CategoryId")
37
- .HasName("PK__BookCate__9C7051A74E7D221D");
38
-
39
- b.HasIndex("CategoryId");
40
-
41
- b.ToTable("BookCategories", (string)null);
42
- });
43
-
44
- modelBuilder.Entity("DbConnect.Entities.Book", b =>
45
- {
46
- b.Property<int>("Id")
47
- .ValueGeneratedOnAdd()
48
- .HasColumnType("int");
49
-
50
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
51
-
52
- b.Property<string>("Author")
53
- .IsRequired()
54
- .HasMaxLength(100)
55
- .HasColumnType("nvarchar(100)");
56
-
57
- b.Property<int>("AvailableCopies")
58
- .ValueGeneratedOnAdd()
59
- .HasColumnType("int")
60
- .HasDefaultValue(1);
61
-
62
- b.Property<string>("CoverUrl")
63
- .HasColumnType("nvarchar(max)");
64
-
65
- b.Property<DateTime>("CreatedAt")
66
- .ValueGeneratedOnAdd()
67
- .HasColumnType("datetime")
68
- .HasDefaultValueSql("(getdate())");
69
-
70
- b.Property<string>("Description")
71
- .HasColumnType("nvarchar(max)");
72
-
73
- b.Property<bool>("IsActive")
74
- .ValueGeneratedOnAdd()
75
- .HasColumnType("bit")
76
- .HasDefaultValue(true);
77
-
78
- b.Property<string>("Isbn")
79
- .IsRequired()
80
- .HasMaxLength(20)
81
- .HasColumnType("nvarchar(20)")
82
- .HasColumnName("ISBN");
83
-
84
- b.Property<string>("Status")
85
- .IsRequired()
86
- .ValueGeneratedOnAdd()
87
- .HasMaxLength(20)
88
- .HasColumnType("nvarchar(20)")
89
- .HasDefaultValue("Available");
90
-
91
- b.Property<string>("Title")
92
- .IsRequired()
93
- .HasMaxLength(200)
94
- .HasColumnType("nvarchar(200)");
95
-
96
- b.Property<int>("TotalCopies")
97
- .ValueGeneratedOnAdd()
98
- .HasColumnType("int")
99
- .HasDefaultValue(1);
100
-
101
- b.Property<DateTime?>("UpdatedAt")
102
- .HasColumnType("datetime");
103
-
104
- b.HasKey("Id")
105
- .HasName("PK__Books__3214EC07AE1974C8");
106
-
107
- b.HasIndex(new[] { "Isbn" }, "UQ__Books__447D36EA79CF66CE")
108
- .IsUnique();
109
-
110
- b.ToTable("Books");
111
- });
112
-
113
- modelBuilder.Entity("DbConnect.Entities.Borrowing", b =>
114
- {
115
- b.Property<Guid>("Id")
116
- .ValueGeneratedOnAdd()
117
- .HasColumnType("uniqueidentifier")
118
- .HasDefaultValueSql("(newid())");
119
-
120
- b.Property<int>("BookId")
121
- .HasColumnType("int");
122
-
123
- b.Property<DateTime>("BorrowDate")
124
- .ValueGeneratedOnAdd()
125
- .HasColumnType("datetime")
126
- .HasDefaultValueSql("(getdate())");
127
-
128
- b.Property<DateTime>("DueDate")
129
- .HasColumnType("datetime");
130
-
131
- b.Property<decimal>("FineAmount")
132
- .HasColumnType("decimal(10, 2)");
133
-
134
- b.Property<bool>("IsFinePaid")
135
- .HasColumnType("bit");
136
-
137
- b.Property<DateTime?>("ReturnDate")
138
- .HasColumnType("datetime");
139
-
140
- b.Property<string>("Status")
141
- .IsRequired()
142
- .ValueGeneratedOnAdd()
143
- .HasMaxLength(20)
144
- .HasColumnType("nvarchar(20)")
145
- .HasDefaultValue("Active");
146
-
147
- b.Property<Guid>("UserId")
148
- .HasColumnType("uniqueidentifier");
149
-
150
- b.HasKey("Id");
151
-
152
- b.HasIndex("BookId");
153
-
154
- b.HasIndex("UserId");
155
-
156
- b.ToTable("Borrowings");
157
- });
158
-
159
- modelBuilder.Entity("DbConnect.Entities.Category", b =>
160
- {
161
- b.Property<int>("Id")
162
- .ValueGeneratedOnAdd()
163
- .HasColumnType("int");
164
-
165
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
166
-
167
- b.Property<string>("Name")
168
- .IsRequired()
169
- .HasMaxLength(100)
170
- .HasColumnType("nvarchar(100)");
171
-
172
- b.HasKey("Id")
173
- .HasName("PK__Categori__3214EC0751B5797D");
174
-
175
- b.HasIndex(new[] { "Name" }, "UQ__Categori__737584F622B16D3A")
176
- .IsUnique();
177
-
178
- b.ToTable("Categories");
179
- });
180
-
181
- modelBuilder.Entity("DbConnect.Entities.Membership", b =>
182
- {
183
- b.Property<int>("Id")
184
- .ValueGeneratedOnAdd()
185
- .HasColumnType("int");
186
-
187
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
188
-
189
- b.Property<int>("BorrowingDays")
190
- .HasColumnType("int");
191
-
192
- b.Property<int>("DurationMonths")
193
- .HasColumnType("int");
194
-
195
- b.Property<int>("MaxBooks")
196
- .HasColumnType("int");
197
-
198
- b.Property<decimal>("Price")
199
- .HasColumnType("decimal(10, 2)");
200
-
201
- b.Property<string>("RewardId")
202
- .HasMaxLength(100)
203
- .HasColumnType("nvarchar(100)");
204
-
205
- b.Property<string>("Type")
206
- .IsRequired()
207
- .HasMaxLength(50)
208
- .HasColumnType("nvarchar(50)");
209
-
210
- b.HasKey("Id")
211
- .HasName("PK__Membersh__3214EC07A6F5A55F");
212
-
213
- b.HasIndex(new[] { "Type" }, "IX_Memberships_Type")
214
- .IsUnique();
215
-
216
- b.ToTable("Memberships");
217
- });
218
-
219
- modelBuilder.Entity("DbConnect.Entities.Notification", b =>
220
- {
221
- b.Property<int>("Id")
222
- .ValueGeneratedOnAdd()
223
- .HasColumnType("int");
224
-
225
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
226
-
227
- b.Property<string>("ActionLink")
228
- .HasMaxLength(500)
229
- .HasColumnType("nvarchar(500)");
230
-
231
- b.Property<string>("ActionText")
232
- .HasMaxLength(100)
233
- .HasColumnType("nvarchar(100)");
234
-
235
- b.Property<DateTime>("CreatedAt")
236
- .ValueGeneratedOnAdd()
237
- .HasColumnType("datetime")
238
- .HasDefaultValueSql("(getdate())");
239
-
240
- b.Property<bool>("IsRead")
241
- .ValueGeneratedOnAdd()
242
- .HasColumnType("bit")
243
- .HasDefaultValue(false);
244
-
245
- b.Property<string>("Message")
246
- .IsRequired()
247
- .HasMaxLength(1000)
248
- .HasColumnType("nvarchar(1000)");
249
-
250
- b.Property<string>("Title")
251
- .IsRequired()
252
- .HasMaxLength(200)
253
- .HasColumnType("nvarchar(200)");
254
-
255
- b.Property<string>("Type")
256
- .IsRequired()
257
- .ValueGeneratedOnAdd()
258
- .HasMaxLength(50)
259
- .HasColumnType("nvarchar(50)")
260
- .HasDefaultValue("Info");
261
-
262
- b.Property<Guid>("UserId")
263
- .HasColumnType("uniqueidentifier");
264
-
265
- b.HasKey("Id");
266
-
267
- b.HasIndex("UserId");
268
-
269
- b.ToTable("Notifications");
270
- });
271
-
272
- modelBuilder.Entity("DbConnect.Entities.User", b =>
273
- {
274
- b.Property<Guid>("Id")
275
- .ValueGeneratedOnAdd()
276
- .HasColumnType("uniqueidentifier")
277
- .HasDefaultValueSql("(newid())");
278
-
279
- b.Property<string>("Address")
280
- .HasMaxLength(255)
281
- .HasColumnType("nvarchar(255)");
282
-
283
- b.Property<bool?>("BanStatus")
284
- .HasColumnType("bit");
285
-
286
- b.Property<DateTime>("CreatedAt")
287
- .ValueGeneratedOnAdd()
288
- .HasColumnType("datetime")
289
- .HasDefaultValueSql("(getdate())");
290
-
291
- b.Property<string>("Email")
292
- .IsRequired()
293
- .HasMaxLength(100)
294
- .HasColumnType("nvarchar(100)");
295
-
296
- b.Property<string>("FullName")
297
- .IsRequired()
298
- .HasMaxLength(100)
299
- .HasColumnType("nvarchar(100)");
300
-
301
- b.Property<bool>("IsActive")
302
- .ValueGeneratedOnAdd()
303
- .HasColumnType("bit")
304
- .HasDefaultValue(true);
305
-
306
- b.Property<string>("PasswordHash")
307
- .IsRequired()
308
- .HasColumnType("nvarchar(max)");
309
-
310
- b.Property<string>("PhoneNumber")
311
- .HasMaxLength(20)
312
- .HasColumnType("nvarchar(20)");
313
-
314
- b.Property<string>("Role")
315
- .IsRequired()
316
- .ValueGeneratedOnAdd()
317
- .HasMaxLength(20)
318
- .HasColumnType("nvarchar(20)")
319
- .HasDefaultValue("User");
320
-
321
- b.Property<string>("StudentId")
322
- .HasMaxLength(20)
323
- .HasColumnType("nvarchar(20)");
324
-
325
- b.Property<DateTime?>("SuspensionEndDate")
326
- .HasColumnType("datetime");
327
-
328
- b.Property<DateTime?>("UpdatedAt")
329
- .HasColumnType("datetime");
330
-
331
- b.HasKey("Id");
332
-
333
- b.HasIndex(new[] { "Email" }, "UQ_Users_Email")
334
- .IsUnique();
335
-
336
- b.ToTable("Users");
337
- });
338
-
339
- modelBuilder.Entity("DbConnect.Entities.UserSubscription", b =>
340
- {
341
- b.Property<Guid>("Id")
342
- .ValueGeneratedOnAdd()
343
- .HasColumnType("uniqueidentifier")
344
- .HasDefaultValueSql("(newid())");
345
-
346
- b.Property<DateTime>("ExpiryDate")
347
- .HasColumnType("datetime");
348
-
349
- b.Property<string>("ExternalRedemptionId")
350
- .HasMaxLength(100)
351
- .HasColumnType("nvarchar(100)");
352
-
353
- b.Property<bool>("IsActive")
354
- .ValueGeneratedOnAdd()
355
- .HasColumnType("bit")
356
- .HasDefaultValue(true);
357
-
358
- b.Property<int>("MembershipId")
359
- .HasColumnType("int");
360
-
361
- b.Property<DateTime>("StartDate")
362
- .HasColumnType("datetime");
363
-
364
- b.Property<string>("Status")
365
- .IsRequired()
366
- .ValueGeneratedOnAdd()
367
- .HasMaxLength(20)
368
- .HasColumnType("nvarchar(20)")
369
- .HasDefaultValue("Active");
370
-
371
- b.Property<Guid>("UserId")
372
- .HasColumnType("uniqueidentifier");
373
-
374
- b.HasKey("Id");
375
-
376
- b.HasIndex("MembershipId");
377
-
378
- b.HasIndex("UserId");
379
-
380
- b.ToTable("UserSubscriptions");
381
- });
382
-
383
- modelBuilder.Entity("BookCategory", b =>
384
- {
385
- b.HasOne("DbConnect.Entities.Book", null)
386
- .WithMany()
387
- .HasForeignKey("BookId")
388
- .OnDelete(DeleteBehavior.Cascade)
389
- .IsRequired()
390
- .HasConstraintName("FK_BookCategories_Books");
391
-
392
- b.HasOne("DbConnect.Entities.Category", null)
393
- .WithMany()
394
- .HasForeignKey("CategoryId")
395
- .OnDelete(DeleteBehavior.Cascade)
396
- .IsRequired()
397
- .HasConstraintName("FK_BookCategories_Categories");
398
- });
399
-
400
- modelBuilder.Entity("DbConnect.Entities.Borrowing", b =>
401
- {
402
- b.HasOne("DbConnect.Entities.Book", "Book")
403
- .WithMany("Borrowings")
404
- .HasForeignKey("BookId")
405
- .IsRequired()
406
- .HasConstraintName("FK_Borrowings_Books");
407
-
408
- b.HasOne("DbConnect.Entities.User", "User")
409
- .WithMany("Borrowings")
410
- .HasForeignKey("UserId")
411
- .IsRequired()
412
- .HasConstraintName("FK_Borrowings_Users");
413
-
414
- b.Navigation("Book");
415
-
416
- b.Navigation("User");
417
- });
418
-
419
- modelBuilder.Entity("DbConnect.Entities.Notification", b =>
420
- {
421
- b.HasOne("DbConnect.Entities.User", "User")
422
- .WithMany()
423
- .HasForeignKey("UserId")
424
- .OnDelete(DeleteBehavior.Cascade)
425
- .IsRequired()
426
- .HasConstraintName("FK_Notifications_Users");
427
-
428
- b.Navigation("User");
429
- });
430
-
431
- modelBuilder.Entity("DbConnect.Entities.UserSubscription", b =>
432
- {
433
- b.HasOne("DbConnect.Entities.Membership", "Membership")
434
- .WithMany("UserSubscriptions")
435
- .HasForeignKey("MembershipId")
436
- .IsRequired()
437
- .HasConstraintName("FK_UserSubscriptions_Memberships");
438
-
439
- b.HasOne("DbConnect.Entities.User", "User")
440
- .WithMany("UserSubscriptions")
441
- .HasForeignKey("UserId")
442
- .IsRequired()
443
- .HasConstraintName("FK_UserSubscriptions_Users");
444
-
445
- b.Navigation("Membership");
446
-
447
- b.Navigation("User");
448
- });
449
-
450
- modelBuilder.Entity("DbConnect.Entities.Book", b =>
451
- {
452
- b.Navigation("Borrowings");
453
- });
454
-
455
- modelBuilder.Entity("DbConnect.Entities.Membership", b =>
456
- {
457
- b.Navigation("UserSubscriptions");
458
- });
459
-
460
- modelBuilder.Entity("DbConnect.Entities.User", b =>
461
- {
462
- b.Navigation("Borrowings");
463
-
464
- b.Navigation("UserSubscriptions");
465
- });
466
- #pragma warning restore 612, 618
467
- }
468
- }
469
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DbConnect/Migrations/20260427043736_AddNotifications.cs DELETED
@@ -1,74 +0,0 @@
1
- using System;
2
- using Microsoft.EntityFrameworkCore.Migrations;
3
-
4
- #nullable disable
5
-
6
- namespace DbConnect.Migrations
7
- {
8
- /// <inheritdoc />
9
- public partial class AddNotifications : Migration
10
- {
11
- /// <inheritdoc />
12
- protected override void Up(MigrationBuilder migrationBuilder)
13
- {
14
- migrationBuilder.CreateTable(
15
- name: "Notifications",
16
- columns: table => new
17
- {
18
- Id = table.Column<int>(type: "int", nullable: false)
19
- .Annotation("SqlServer:Identity", "1, 1"),
20
- UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
21
- Title = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
22
- Message = table.Column<string>(type: "nvarchar(1000)", maxLength: 1000, nullable: false),
23
- Type = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false, defaultValue: "Info"),
24
- ActionLink = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
25
- ActionText = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
26
- IsRead = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
27
- CreatedAt = table.Column<DateTime>(type: "datetime", nullable: false, defaultValueSql: "(getdate())")
28
- },
29
- constraints: table =>
30
- {
31
- table.PrimaryKey("PK_Notifications", x => x.Id);
32
- table.ForeignKey(
33
- name: "FK_Notifications_Users",
34
- column: x => x.UserId,
35
- principalTable: "Users",
36
- principalColumn: "Id",
37
- onDelete: ReferentialAction.Cascade);
38
- });
39
-
40
- migrationBuilder.CreateIndex(
41
- name: "IX_Notifications_UserId",
42
- table: "Notifications",
43
- column: "UserId");
44
- }
45
-
46
- /// <inheritdoc />
47
- protected override void Down(MigrationBuilder migrationBuilder)
48
- {
49
- migrationBuilder.DropTable(
50
- name: "BookCategories");
51
-
52
- migrationBuilder.DropTable(
53
- name: "Borrowings");
54
-
55
- migrationBuilder.DropTable(
56
- name: "Notifications");
57
-
58
- migrationBuilder.DropTable(
59
- name: "UserSubscriptions");
60
-
61
- migrationBuilder.DropTable(
62
- name: "Categories");
63
-
64
- migrationBuilder.DropTable(
65
- name: "Books");
66
-
67
- migrationBuilder.DropTable(
68
- name: "Memberships");
69
-
70
- migrationBuilder.DropTable(
71
- name: "Users");
72
- }
73
- }
74
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DbConnect/Migrations/20260427052139_UpdateUserWithFcmToken.Designer.cs DELETED
@@ -1,473 +0,0 @@
1
- // <auto-generated />
2
- using System;
3
- using DbConnect.Data;
4
- using Microsoft.EntityFrameworkCore;
5
- using Microsoft.EntityFrameworkCore.Infrastructure;
6
- using Microsoft.EntityFrameworkCore.Metadata;
7
- using Microsoft.EntityFrameworkCore.Migrations;
8
- using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
9
-
10
- #nullable disable
11
-
12
- namespace DbConnect.Migrations
13
- {
14
- [DbContext(typeof(AppDbContext))]
15
- [Migration("20260427052139_UpdateUserWithFcmToken")]
16
- partial class UpdateUserWithFcmToken
17
- {
18
- /// <inheritdoc />
19
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
20
- {
21
- #pragma warning disable 612, 618
22
- modelBuilder
23
- .HasAnnotation("ProductVersion", "9.0.0")
24
- .HasAnnotation("Relational:MaxIdentifierLength", 128);
25
-
26
- SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
27
-
28
- modelBuilder.Entity("BookCategory", b =>
29
- {
30
- b.Property<int>("BookId")
31
- .HasColumnType("int");
32
-
33
- b.Property<int>("CategoryId")
34
- .HasColumnType("int");
35
-
36
- b.HasKey("BookId", "CategoryId")
37
- .HasName("PK__BookCate__9C7051A74E7D221D");
38
-
39
- b.HasIndex("CategoryId");
40
-
41
- b.ToTable("BookCategories", (string)null);
42
- });
43
-
44
- modelBuilder.Entity("DbConnect.Entities.Book", b =>
45
- {
46
- b.Property<int>("Id")
47
- .ValueGeneratedOnAdd()
48
- .HasColumnType("int");
49
-
50
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
51
-
52
- b.Property<string>("Author")
53
- .IsRequired()
54
- .HasMaxLength(100)
55
- .HasColumnType("nvarchar(100)");
56
-
57
- b.Property<int>("AvailableCopies")
58
- .ValueGeneratedOnAdd()
59
- .HasColumnType("int")
60
- .HasDefaultValue(1);
61
-
62
- b.Property<string>("CoverUrl")
63
- .HasColumnType("nvarchar(max)");
64
-
65
- b.Property<DateTime>("CreatedAt")
66
- .ValueGeneratedOnAdd()
67
- .HasColumnType("datetime")
68
- .HasDefaultValueSql("(getdate())");
69
-
70
- b.Property<string>("Description")
71
- .HasColumnType("nvarchar(max)");
72
-
73
- b.Property<bool>("IsActive")
74
- .ValueGeneratedOnAdd()
75
- .HasColumnType("bit")
76
- .HasDefaultValue(true);
77
-
78
- b.Property<string>("Isbn")
79
- .IsRequired()
80
- .HasMaxLength(20)
81
- .HasColumnType("nvarchar(20)")
82
- .HasColumnName("ISBN");
83
-
84
- b.Property<string>("Status")
85
- .IsRequired()
86
- .ValueGeneratedOnAdd()
87
- .HasMaxLength(20)
88
- .HasColumnType("nvarchar(20)")
89
- .HasDefaultValue("Available");
90
-
91
- b.Property<string>("Title")
92
- .IsRequired()
93
- .HasMaxLength(200)
94
- .HasColumnType("nvarchar(200)");
95
-
96
- b.Property<int>("TotalCopies")
97
- .ValueGeneratedOnAdd()
98
- .HasColumnType("int")
99
- .HasDefaultValue(1);
100
-
101
- b.Property<DateTime?>("UpdatedAt")
102
- .HasColumnType("datetime");
103
-
104
- b.HasKey("Id")
105
- .HasName("PK__Books__3214EC07AE1974C8");
106
-
107
- b.HasIndex(new[] { "Isbn" }, "UQ__Books__447D36EA79CF66CE")
108
- .IsUnique();
109
-
110
- b.ToTable("Books");
111
- });
112
-
113
- modelBuilder.Entity("DbConnect.Entities.Borrowing", b =>
114
- {
115
- b.Property<Guid>("Id")
116
- .ValueGeneratedOnAdd()
117
- .HasColumnType("uniqueidentifier")
118
- .HasDefaultValueSql("(newid())");
119
-
120
- b.Property<int>("BookId")
121
- .HasColumnType("int");
122
-
123
- b.Property<DateTime>("BorrowDate")
124
- .ValueGeneratedOnAdd()
125
- .HasColumnType("datetime")
126
- .HasDefaultValueSql("(getdate())");
127
-
128
- b.Property<DateTime>("DueDate")
129
- .HasColumnType("datetime");
130
-
131
- b.Property<decimal>("FineAmount")
132
- .HasColumnType("decimal(10, 2)");
133
-
134
- b.Property<bool>("IsFinePaid")
135
- .HasColumnType("bit");
136
-
137
- b.Property<DateTime?>("ReturnDate")
138
- .HasColumnType("datetime");
139
-
140
- b.Property<string>("Status")
141
- .IsRequired()
142
- .ValueGeneratedOnAdd()
143
- .HasMaxLength(20)
144
- .HasColumnType("nvarchar(20)")
145
- .HasDefaultValue("Active");
146
-
147
- b.Property<Guid>("UserId")
148
- .HasColumnType("uniqueidentifier");
149
-
150
- b.HasKey("Id");
151
-
152
- b.HasIndex("BookId");
153
-
154
- b.HasIndex("UserId");
155
-
156
- b.ToTable("Borrowings");
157
- });
158
-
159
- modelBuilder.Entity("DbConnect.Entities.Category", b =>
160
- {
161
- b.Property<int>("Id")
162
- .ValueGeneratedOnAdd()
163
- .HasColumnType("int");
164
-
165
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
166
-
167
- b.Property<string>("Name")
168
- .IsRequired()
169
- .HasMaxLength(100)
170
- .HasColumnType("nvarchar(100)");
171
-
172
- b.HasKey("Id")
173
- .HasName("PK__Categori__3214EC0751B5797D");
174
-
175
- b.HasIndex(new[] { "Name" }, "UQ__Categori__737584F622B16D3A")
176
- .IsUnique();
177
-
178
- b.ToTable("Categories");
179
- });
180
-
181
- modelBuilder.Entity("DbConnect.Entities.Membership", b =>
182
- {
183
- b.Property<int>("Id")
184
- .ValueGeneratedOnAdd()
185
- .HasColumnType("int");
186
-
187
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
188
-
189
- b.Property<int>("BorrowingDays")
190
- .HasColumnType("int");
191
-
192
- b.Property<int>("DurationMonths")
193
- .HasColumnType("int");
194
-
195
- b.Property<int>("MaxBooks")
196
- .HasColumnType("int");
197
-
198
- b.Property<decimal>("Price")
199
- .HasColumnType("decimal(10, 2)");
200
-
201
- b.Property<string>("RewardId")
202
- .HasMaxLength(100)
203
- .HasColumnType("nvarchar(100)");
204
-
205
- b.Property<string>("Type")
206
- .IsRequired()
207
- .HasMaxLength(50)
208
- .HasColumnType("nvarchar(50)");
209
-
210
- b.HasKey("Id")
211
- .HasName("PK__Membersh__3214EC07A6F5A55F");
212
-
213
- b.HasIndex(new[] { "Type" }, "IX_Memberships_Type")
214
- .IsUnique();
215
-
216
- b.ToTable("Memberships");
217
- });
218
-
219
- modelBuilder.Entity("DbConnect.Entities.Notification", b =>
220
- {
221
- b.Property<int>("Id")
222
- .ValueGeneratedOnAdd()
223
- .HasColumnType("int");
224
-
225
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
226
-
227
- b.Property<string>("ActionLink")
228
- .HasMaxLength(500)
229
- .HasColumnType("nvarchar(500)");
230
-
231
- b.Property<string>("ActionText")
232
- .HasMaxLength(100)
233
- .HasColumnType("nvarchar(100)");
234
-
235
- b.Property<DateTime>("CreatedAt")
236
- .ValueGeneratedOnAdd()
237
- .HasColumnType("datetime")
238
- .HasDefaultValueSql("(getdate())");
239
-
240
- b.Property<bool>("IsRead")
241
- .ValueGeneratedOnAdd()
242
- .HasColumnType("bit")
243
- .HasDefaultValue(false);
244
-
245
- b.Property<string>("Message")
246
- .IsRequired()
247
- .HasMaxLength(1000)
248
- .HasColumnType("nvarchar(1000)");
249
-
250
- b.Property<string>("Title")
251
- .IsRequired()
252
- .HasMaxLength(200)
253
- .HasColumnType("nvarchar(200)");
254
-
255
- b.Property<string>("Type")
256
- .IsRequired()
257
- .ValueGeneratedOnAdd()
258
- .HasMaxLength(50)
259
- .HasColumnType("nvarchar(50)")
260
- .HasDefaultValue("Info");
261
-
262
- b.Property<Guid>("UserId")
263
- .HasColumnType("uniqueidentifier");
264
-
265
- b.HasKey("Id");
266
-
267
- b.HasIndex("UserId");
268
-
269
- b.ToTable("Notifications");
270
- });
271
-
272
- modelBuilder.Entity("DbConnect.Entities.User", b =>
273
- {
274
- b.Property<Guid>("Id")
275
- .ValueGeneratedOnAdd()
276
- .HasColumnType("uniqueidentifier")
277
- .HasDefaultValueSql("(newid())");
278
-
279
- b.Property<string>("Address")
280
- .HasMaxLength(255)
281
- .HasColumnType("nvarchar(255)");
282
-
283
- b.Property<bool?>("BanStatus")
284
- .HasColumnType("bit");
285
-
286
- b.Property<DateTime>("CreatedAt")
287
- .ValueGeneratedOnAdd()
288
- .HasColumnType("datetime")
289
- .HasDefaultValueSql("(getdate())");
290
-
291
- b.Property<string>("Email")
292
- .IsRequired()
293
- .HasMaxLength(100)
294
- .HasColumnType("nvarchar(100)");
295
-
296
- b.Property<string>("FcmToken")
297
- .HasMaxLength(500)
298
- .HasColumnType("nvarchar(500)");
299
-
300
- b.Property<string>("FullName")
301
- .IsRequired()
302
- .HasMaxLength(100)
303
- .HasColumnType("nvarchar(100)");
304
-
305
- b.Property<bool>("IsActive")
306
- .ValueGeneratedOnAdd()
307
- .HasColumnType("bit")
308
- .HasDefaultValue(true);
309
-
310
- b.Property<string>("PasswordHash")
311
- .IsRequired()
312
- .HasColumnType("nvarchar(max)");
313
-
314
- b.Property<string>("PhoneNumber")
315
- .HasMaxLength(20)
316
- .HasColumnType("nvarchar(20)");
317
-
318
- b.Property<string>("Role")
319
- .IsRequired()
320
- .ValueGeneratedOnAdd()
321
- .HasMaxLength(20)
322
- .HasColumnType("nvarchar(20)")
323
- .HasDefaultValue("User");
324
-
325
- b.Property<string>("StudentId")
326
- .HasMaxLength(20)
327
- .HasColumnType("nvarchar(20)");
328
-
329
- b.Property<DateTime?>("SuspensionEndDate")
330
- .HasColumnType("datetime");
331
-
332
- b.Property<DateTime?>("UpdatedAt")
333
- .HasColumnType("datetime");
334
-
335
- b.HasKey("Id");
336
-
337
- b.HasIndex(new[] { "Email" }, "UQ_Users_Email")
338
- .IsUnique();
339
-
340
- b.ToTable("Users");
341
- });
342
-
343
- modelBuilder.Entity("DbConnect.Entities.UserSubscription", b =>
344
- {
345
- b.Property<Guid>("Id")
346
- .ValueGeneratedOnAdd()
347
- .HasColumnType("uniqueidentifier")
348
- .HasDefaultValueSql("(newid())");
349
-
350
- b.Property<DateTime>("ExpiryDate")
351
- .HasColumnType("datetime");
352
-
353
- b.Property<string>("ExternalRedemptionId")
354
- .HasMaxLength(100)
355
- .HasColumnType("nvarchar(100)");
356
-
357
- b.Property<bool>("IsActive")
358
- .ValueGeneratedOnAdd()
359
- .HasColumnType("bit")
360
- .HasDefaultValue(true);
361
-
362
- b.Property<int>("MembershipId")
363
- .HasColumnType("int");
364
-
365
- b.Property<DateTime>("StartDate")
366
- .HasColumnType("datetime");
367
-
368
- b.Property<string>("Status")
369
- .IsRequired()
370
- .ValueGeneratedOnAdd()
371
- .HasMaxLength(20)
372
- .HasColumnType("nvarchar(20)")
373
- .HasDefaultValue("Active");
374
-
375
- b.Property<Guid>("UserId")
376
- .HasColumnType("uniqueidentifier");
377
-
378
- b.HasKey("Id");
379
-
380
- b.HasIndex("MembershipId");
381
-
382
- b.HasIndex("UserId");
383
-
384
- b.ToTable("UserSubscriptions");
385
- });
386
-
387
- modelBuilder.Entity("BookCategory", b =>
388
- {
389
- b.HasOne("DbConnect.Entities.Book", null)
390
- .WithMany()
391
- .HasForeignKey("BookId")
392
- .OnDelete(DeleteBehavior.Cascade)
393
- .IsRequired()
394
- .HasConstraintName("FK_BookCategories_Books");
395
-
396
- b.HasOne("DbConnect.Entities.Category", null)
397
- .WithMany()
398
- .HasForeignKey("CategoryId")
399
- .OnDelete(DeleteBehavior.Cascade)
400
- .IsRequired()
401
- .HasConstraintName("FK_BookCategories_Categories");
402
- });
403
-
404
- modelBuilder.Entity("DbConnect.Entities.Borrowing", b =>
405
- {
406
- b.HasOne("DbConnect.Entities.Book", "Book")
407
- .WithMany("Borrowings")
408
- .HasForeignKey("BookId")
409
- .IsRequired()
410
- .HasConstraintName("FK_Borrowings_Books");
411
-
412
- b.HasOne("DbConnect.Entities.User", "User")
413
- .WithMany("Borrowings")
414
- .HasForeignKey("UserId")
415
- .IsRequired()
416
- .HasConstraintName("FK_Borrowings_Users");
417
-
418
- b.Navigation("Book");
419
-
420
- b.Navigation("User");
421
- });
422
-
423
- modelBuilder.Entity("DbConnect.Entities.Notification", b =>
424
- {
425
- b.HasOne("DbConnect.Entities.User", "User")
426
- .WithMany()
427
- .HasForeignKey("UserId")
428
- .OnDelete(DeleteBehavior.Cascade)
429
- .IsRequired()
430
- .HasConstraintName("FK_Notifications_Users");
431
-
432
- b.Navigation("User");
433
- });
434
-
435
- modelBuilder.Entity("DbConnect.Entities.UserSubscription", b =>
436
- {
437
- b.HasOne("DbConnect.Entities.Membership", "Membership")
438
- .WithMany("UserSubscriptions")
439
- .HasForeignKey("MembershipId")
440
- .IsRequired()
441
- .HasConstraintName("FK_UserSubscriptions_Memberships");
442
-
443
- b.HasOne("DbConnect.Entities.User", "User")
444
- .WithMany("UserSubscriptions")
445
- .HasForeignKey("UserId")
446
- .IsRequired()
447
- .HasConstraintName("FK_UserSubscriptions_Users");
448
-
449
- b.Navigation("Membership");
450
-
451
- b.Navigation("User");
452
- });
453
-
454
- modelBuilder.Entity("DbConnect.Entities.Book", b =>
455
- {
456
- b.Navigation("Borrowings");
457
- });
458
-
459
- modelBuilder.Entity("DbConnect.Entities.Membership", b =>
460
- {
461
- b.Navigation("UserSubscriptions");
462
- });
463
-
464
- modelBuilder.Entity("DbConnect.Entities.User", b =>
465
- {
466
- b.Navigation("Borrowings");
467
-
468
- b.Navigation("UserSubscriptions");
469
- });
470
- #pragma warning restore 612, 618
471
- }
472
- }
473
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DbConnect/Migrations/20260427052139_UpdateUserWithFcmToken.cs DELETED
@@ -1,29 +0,0 @@
1
- using Microsoft.EntityFrameworkCore.Migrations;
2
-
3
- #nullable disable
4
-
5
- namespace DbConnect.Migrations
6
- {
7
- /// <inheritdoc />
8
- public partial class UpdateUserWithFcmToken : Migration
9
- {
10
- /// <inheritdoc />
11
- protected override void Up(MigrationBuilder migrationBuilder)
12
- {
13
- migrationBuilder.AddColumn<string>(
14
- name: "FcmToken",
15
- table: "Users",
16
- type: "nvarchar(500)",
17
- maxLength: 500,
18
- nullable: true);
19
- }
20
-
21
- /// <inheritdoc />
22
- protected override void Down(MigrationBuilder migrationBuilder)
23
- {
24
- migrationBuilder.DropColumn(
25
- name: "FcmToken",
26
- table: "Users");
27
- }
28
- }
29
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DbConnect/Migrations/20260427071940_AddWishlistItems.Designer.cs DELETED
@@ -1,522 +0,0 @@
1
- // <auto-generated />
2
- using System;
3
- using DbConnect.Data;
4
- using Microsoft.EntityFrameworkCore;
5
- using Microsoft.EntityFrameworkCore.Infrastructure;
6
- using Microsoft.EntityFrameworkCore.Metadata;
7
- using Microsoft.EntityFrameworkCore.Migrations;
8
- using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
9
-
10
- #nullable disable
11
-
12
- namespace DbConnect.Migrations
13
- {
14
- [DbContext(typeof(AppDbContext))]
15
- [Migration("20260427071940_AddWishlistItems")]
16
- partial class AddWishlistItems
17
- {
18
- /// <inheritdoc />
19
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
20
- {
21
- #pragma warning disable 612, 618
22
- modelBuilder
23
- .HasAnnotation("ProductVersion", "9.0.0")
24
- .HasAnnotation("Relational:MaxIdentifierLength", 128);
25
-
26
- SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
27
-
28
- modelBuilder.Entity("BookCategory", b =>
29
- {
30
- b.Property<int>("BookId")
31
- .HasColumnType("int");
32
-
33
- b.Property<int>("CategoryId")
34
- .HasColumnType("int");
35
-
36
- b.HasKey("BookId", "CategoryId")
37
- .HasName("PK__BookCate__9C7051A74E7D221D");
38
-
39
- b.HasIndex("CategoryId");
40
-
41
- b.ToTable("BookCategories", (string)null);
42
- });
43
-
44
- modelBuilder.Entity("DbConnect.Entities.Book", b =>
45
- {
46
- b.Property<int>("Id")
47
- .ValueGeneratedOnAdd()
48
- .HasColumnType("int");
49
-
50
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
51
-
52
- b.Property<string>("Author")
53
- .IsRequired()
54
- .HasMaxLength(100)
55
- .HasColumnType("nvarchar(100)");
56
-
57
- b.Property<int>("AvailableCopies")
58
- .ValueGeneratedOnAdd()
59
- .HasColumnType("int")
60
- .HasDefaultValue(1);
61
-
62
- b.Property<string>("CoverUrl")
63
- .HasColumnType("nvarchar(max)");
64
-
65
- b.Property<DateTime>("CreatedAt")
66
- .ValueGeneratedOnAdd()
67
- .HasColumnType("datetime")
68
- .HasDefaultValueSql("(getdate())");
69
-
70
- b.Property<string>("Description")
71
- .HasColumnType("nvarchar(max)");
72
-
73
- b.Property<bool>("IsActive")
74
- .ValueGeneratedOnAdd()
75
- .HasColumnType("bit")
76
- .HasDefaultValue(true);
77
-
78
- b.Property<string>("Isbn")
79
- .IsRequired()
80
- .HasMaxLength(20)
81
- .HasColumnType("nvarchar(20)")
82
- .HasColumnName("ISBN");
83
-
84
- b.Property<string>("Status")
85
- .IsRequired()
86
- .ValueGeneratedOnAdd()
87
- .HasMaxLength(20)
88
- .HasColumnType("nvarchar(20)")
89
- .HasDefaultValue("Available");
90
-
91
- b.Property<string>("Title")
92
- .IsRequired()
93
- .HasMaxLength(200)
94
- .HasColumnType("nvarchar(200)");
95
-
96
- b.Property<int>("TotalCopies")
97
- .ValueGeneratedOnAdd()
98
- .HasColumnType("int")
99
- .HasDefaultValue(1);
100
-
101
- b.Property<DateTime?>("UpdatedAt")
102
- .HasColumnType("datetime");
103
-
104
- b.HasKey("Id")
105
- .HasName("PK__Books__3214EC07AE1974C8");
106
-
107
- b.HasIndex(new[] { "Isbn" }, "UQ__Books__447D36EA79CF66CE")
108
- .IsUnique();
109
-
110
- b.ToTable("Books");
111
- });
112
-
113
- modelBuilder.Entity("DbConnect.Entities.Borrowing", b =>
114
- {
115
- b.Property<Guid>("Id")
116
- .ValueGeneratedOnAdd()
117
- .HasColumnType("uniqueidentifier")
118
- .HasDefaultValueSql("(newid())");
119
-
120
- b.Property<int>("BookId")
121
- .HasColumnType("int");
122
-
123
- b.Property<DateTime>("BorrowDate")
124
- .ValueGeneratedOnAdd()
125
- .HasColumnType("datetime")
126
- .HasDefaultValueSql("(getdate())");
127
-
128
- b.Property<DateTime>("DueDate")
129
- .HasColumnType("datetime");
130
-
131
- b.Property<decimal>("FineAmount")
132
- .HasColumnType("decimal(10, 2)");
133
-
134
- b.Property<bool>("IsFinePaid")
135
- .HasColumnType("bit");
136
-
137
- b.Property<DateTime?>("ReturnDate")
138
- .HasColumnType("datetime");
139
-
140
- b.Property<string>("Status")
141
- .IsRequired()
142
- .ValueGeneratedOnAdd()
143
- .HasMaxLength(20)
144
- .HasColumnType("nvarchar(20)")
145
- .HasDefaultValue("Active");
146
-
147
- b.Property<Guid>("UserId")
148
- .HasColumnType("uniqueidentifier");
149
-
150
- b.HasKey("Id");
151
-
152
- b.HasIndex("BookId");
153
-
154
- b.HasIndex("UserId");
155
-
156
- b.ToTable("Borrowings");
157
- });
158
-
159
- modelBuilder.Entity("DbConnect.Entities.Category", b =>
160
- {
161
- b.Property<int>("Id")
162
- .ValueGeneratedOnAdd()
163
- .HasColumnType("int");
164
-
165
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
166
-
167
- b.Property<string>("Name")
168
- .IsRequired()
169
- .HasMaxLength(100)
170
- .HasColumnType("nvarchar(100)");
171
-
172
- b.HasKey("Id")
173
- .HasName("PK__Categori__3214EC0751B5797D");
174
-
175
- b.HasIndex(new[] { "Name" }, "UQ__Categori__737584F622B16D3A")
176
- .IsUnique();
177
-
178
- b.ToTable("Categories");
179
- });
180
-
181
- modelBuilder.Entity("DbConnect.Entities.Membership", b =>
182
- {
183
- b.Property<int>("Id")
184
- .ValueGeneratedOnAdd()
185
- .HasColumnType("int");
186
-
187
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
188
-
189
- b.Property<int>("BorrowingDays")
190
- .HasColumnType("int");
191
-
192
- b.Property<int>("DurationMonths")
193
- .HasColumnType("int");
194
-
195
- b.Property<int>("MaxBooks")
196
- .HasColumnType("int");
197
-
198
- b.Property<decimal>("Price")
199
- .HasColumnType("decimal(10, 2)");
200
-
201
- b.Property<string>("RewardId")
202
- .HasMaxLength(100)
203
- .HasColumnType("nvarchar(100)");
204
-
205
- b.Property<string>("Type")
206
- .IsRequired()
207
- .HasMaxLength(50)
208
- .HasColumnType("nvarchar(50)");
209
-
210
- b.HasKey("Id")
211
- .HasName("PK__Membersh__3214EC07A6F5A55F");
212
-
213
- b.HasIndex(new[] { "Type" }, "IX_Memberships_Type")
214
- .IsUnique();
215
-
216
- b.ToTable("Memberships");
217
- });
218
-
219
- modelBuilder.Entity("DbConnect.Entities.Notification", b =>
220
- {
221
- b.Property<int>("Id")
222
- .ValueGeneratedOnAdd()
223
- .HasColumnType("int");
224
-
225
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
226
-
227
- b.Property<string>("ActionLink")
228
- .HasMaxLength(500)
229
- .HasColumnType("nvarchar(500)");
230
-
231
- b.Property<string>("ActionText")
232
- .HasMaxLength(100)
233
- .HasColumnType("nvarchar(100)");
234
-
235
- b.Property<DateTime>("CreatedAt")
236
- .ValueGeneratedOnAdd()
237
- .HasColumnType("datetime")
238
- .HasDefaultValueSql("(getdate())");
239
-
240
- b.Property<bool>("IsRead")
241
- .ValueGeneratedOnAdd()
242
- .HasColumnType("bit")
243
- .HasDefaultValue(false);
244
-
245
- b.Property<string>("Message")
246
- .IsRequired()
247
- .HasMaxLength(1000)
248
- .HasColumnType("nvarchar(1000)");
249
-
250
- b.Property<string>("Title")
251
- .IsRequired()
252
- .HasMaxLength(200)
253
- .HasColumnType("nvarchar(200)");
254
-
255
- b.Property<string>("Type")
256
- .IsRequired()
257
- .ValueGeneratedOnAdd()
258
- .HasMaxLength(50)
259
- .HasColumnType("nvarchar(50)")
260
- .HasDefaultValue("Info");
261
-
262
- b.Property<Guid>("UserId")
263
- .HasColumnType("uniqueidentifier");
264
-
265
- b.HasKey("Id");
266
-
267
- b.HasIndex("UserId");
268
-
269
- b.ToTable("Notifications");
270
- });
271
-
272
- modelBuilder.Entity("DbConnect.Entities.User", b =>
273
- {
274
- b.Property<Guid>("Id")
275
- .ValueGeneratedOnAdd()
276
- .HasColumnType("uniqueidentifier")
277
- .HasDefaultValueSql("(newid())");
278
-
279
- b.Property<string>("Address")
280
- .HasMaxLength(255)
281
- .HasColumnType("nvarchar(255)");
282
-
283
- b.Property<bool?>("BanStatus")
284
- .HasColumnType("bit");
285
-
286
- b.Property<DateTime>("CreatedAt")
287
- .ValueGeneratedOnAdd()
288
- .HasColumnType("datetime")
289
- .HasDefaultValueSql("(getdate())");
290
-
291
- b.Property<string>("Email")
292
- .IsRequired()
293
- .HasMaxLength(100)
294
- .HasColumnType("nvarchar(100)");
295
-
296
- b.Property<string>("FcmToken")
297
- .HasMaxLength(500)
298
- .HasColumnType("nvarchar(500)");
299
-
300
- b.Property<string>("FullName")
301
- .IsRequired()
302
- .HasMaxLength(100)
303
- .HasColumnType("nvarchar(100)");
304
-
305
- b.Property<bool>("IsActive")
306
- .ValueGeneratedOnAdd()
307
- .HasColumnType("bit")
308
- .HasDefaultValue(true);
309
-
310
- b.Property<string>("PasswordHash")
311
- .IsRequired()
312
- .HasColumnType("nvarchar(max)");
313
-
314
- b.Property<string>("PhoneNumber")
315
- .HasMaxLength(20)
316
- .HasColumnType("nvarchar(20)");
317
-
318
- b.Property<string>("Role")
319
- .IsRequired()
320
- .ValueGeneratedOnAdd()
321
- .HasMaxLength(20)
322
- .HasColumnType("nvarchar(20)")
323
- .HasDefaultValue("User");
324
-
325
- b.Property<string>("StudentId")
326
- .HasMaxLength(20)
327
- .HasColumnType("nvarchar(20)");
328
-
329
- b.Property<DateTime?>("SuspensionEndDate")
330
- .HasColumnType("datetime");
331
-
332
- b.Property<DateTime?>("UpdatedAt")
333
- .HasColumnType("datetime");
334
-
335
- b.HasKey("Id");
336
-
337
- b.HasIndex(new[] { "Email" }, "UQ_Users_Email")
338
- .IsUnique();
339
-
340
- b.ToTable("Users");
341
- });
342
-
343
- modelBuilder.Entity("DbConnect.Entities.UserSubscription", b =>
344
- {
345
- b.Property<Guid>("Id")
346
- .ValueGeneratedOnAdd()
347
- .HasColumnType("uniqueidentifier")
348
- .HasDefaultValueSql("(newid())");
349
-
350
- b.Property<DateTime>("ExpiryDate")
351
- .HasColumnType("datetime");
352
-
353
- b.Property<string>("ExternalRedemptionId")
354
- .HasMaxLength(100)
355
- .HasColumnType("nvarchar(100)");
356
-
357
- b.Property<bool>("IsActive")
358
- .ValueGeneratedOnAdd()
359
- .HasColumnType("bit")
360
- .HasDefaultValue(true);
361
-
362
- b.Property<int>("MembershipId")
363
- .HasColumnType("int");
364
-
365
- b.Property<DateTime>("StartDate")
366
- .HasColumnType("datetime");
367
-
368
- b.Property<string>("Status")
369
- .IsRequired()
370
- .ValueGeneratedOnAdd()
371
- .HasMaxLength(20)
372
- .HasColumnType("nvarchar(20)")
373
- .HasDefaultValue("Active");
374
-
375
- b.Property<Guid>("UserId")
376
- .HasColumnType("uniqueidentifier");
377
-
378
- b.HasKey("Id");
379
-
380
- b.HasIndex("MembershipId");
381
-
382
- b.HasIndex("UserId");
383
-
384
- b.ToTable("UserSubscriptions");
385
- });
386
-
387
- modelBuilder.Entity("DbConnect.Entities.WishlistItem", b =>
388
- {
389
- b.Property<int>("Id")
390
- .ValueGeneratedOnAdd()
391
- .HasColumnType("int");
392
-
393
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
394
-
395
- b.Property<DateTime>("AddedAt")
396
- .ValueGeneratedOnAdd()
397
- .HasColumnType("datetime")
398
- .HasDefaultValueSql("(getdate())");
399
-
400
- b.Property<int>("BookId")
401
- .HasColumnType("int");
402
-
403
- b.Property<Guid>("UserId")
404
- .HasColumnType("uniqueidentifier");
405
-
406
- b.HasKey("Id");
407
-
408
- b.HasIndex("BookId");
409
-
410
- b.HasIndex("UserId");
411
-
412
- b.ToTable("WishlistItems");
413
- });
414
-
415
- modelBuilder.Entity("BookCategory", b =>
416
- {
417
- b.HasOne("DbConnect.Entities.Book", null)
418
- .WithMany()
419
- .HasForeignKey("BookId")
420
- .OnDelete(DeleteBehavior.Cascade)
421
- .IsRequired()
422
- .HasConstraintName("FK_BookCategories_Books");
423
-
424
- b.HasOne("DbConnect.Entities.Category", null)
425
- .WithMany()
426
- .HasForeignKey("CategoryId")
427
- .OnDelete(DeleteBehavior.Cascade)
428
- .IsRequired()
429
- .HasConstraintName("FK_BookCategories_Categories");
430
- });
431
-
432
- modelBuilder.Entity("DbConnect.Entities.Borrowing", b =>
433
- {
434
- b.HasOne("DbConnect.Entities.Book", "Book")
435
- .WithMany("Borrowings")
436
- .HasForeignKey("BookId")
437
- .IsRequired()
438
- .HasConstraintName("FK_Borrowings_Books");
439
-
440
- b.HasOne("DbConnect.Entities.User", "User")
441
- .WithMany("Borrowings")
442
- .HasForeignKey("UserId")
443
- .IsRequired()
444
- .HasConstraintName("FK_Borrowings_Users");
445
-
446
- b.Navigation("Book");
447
-
448
- b.Navigation("User");
449
- });
450
-
451
- modelBuilder.Entity("DbConnect.Entities.Notification", b =>
452
- {
453
- b.HasOne("DbConnect.Entities.User", "User")
454
- .WithMany()
455
- .HasForeignKey("UserId")
456
- .OnDelete(DeleteBehavior.Cascade)
457
- .IsRequired()
458
- .HasConstraintName("FK_Notifications_Users");
459
-
460
- b.Navigation("User");
461
- });
462
-
463
- modelBuilder.Entity("DbConnect.Entities.UserSubscription", b =>
464
- {
465
- b.HasOne("DbConnect.Entities.Membership", "Membership")
466
- .WithMany("UserSubscriptions")
467
- .HasForeignKey("MembershipId")
468
- .IsRequired()
469
- .HasConstraintName("FK_UserSubscriptions_Memberships");
470
-
471
- b.HasOne("DbConnect.Entities.User", "User")
472
- .WithMany("UserSubscriptions")
473
- .HasForeignKey("UserId")
474
- .IsRequired()
475
- .HasConstraintName("FK_UserSubscriptions_Users");
476
-
477
- b.Navigation("Membership");
478
-
479
- b.Navigation("User");
480
- });
481
-
482
- modelBuilder.Entity("DbConnect.Entities.WishlistItem", b =>
483
- {
484
- b.HasOne("DbConnect.Entities.Book", "Book")
485
- .WithMany()
486
- .HasForeignKey("BookId")
487
- .OnDelete(DeleteBehavior.Cascade)
488
- .IsRequired()
489
- .HasConstraintName("FK_WishlistItems_Books");
490
-
491
- b.HasOne("DbConnect.Entities.User", "User")
492
- .WithMany()
493
- .HasForeignKey("UserId")
494
- .OnDelete(DeleteBehavior.Cascade)
495
- .IsRequired()
496
- .HasConstraintName("FK_WishlistItems_Users");
497
-
498
- b.Navigation("Book");
499
-
500
- b.Navigation("User");
501
- });
502
-
503
- modelBuilder.Entity("DbConnect.Entities.Book", b =>
504
- {
505
- b.Navigation("Borrowings");
506
- });
507
-
508
- modelBuilder.Entity("DbConnect.Entities.Membership", b =>
509
- {
510
- b.Navigation("UserSubscriptions");
511
- });
512
-
513
- modelBuilder.Entity("DbConnect.Entities.User", b =>
514
- {
515
- b.Navigation("Borrowings");
516
-
517
- b.Navigation("UserSubscriptions");
518
- });
519
- #pragma warning restore 612, 618
520
- }
521
- }
522
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DbConnect/Migrations/20260427071940_AddWishlistItems.cs DELETED
@@ -1,59 +0,0 @@
1
- using System;
2
- using Microsoft.EntityFrameworkCore.Migrations;
3
-
4
- #nullable disable
5
-
6
- namespace DbConnect.Migrations
7
- {
8
- /// <inheritdoc />
9
- public partial class AddWishlistItems : Migration
10
- {
11
- /// <inheritdoc />
12
- protected override void Up(MigrationBuilder migrationBuilder)
13
- {
14
- migrationBuilder.CreateTable(
15
- name: "WishlistItems",
16
- columns: table => new
17
- {
18
- Id = table.Column<int>(type: "int", nullable: false)
19
- .Annotation("SqlServer:Identity", "1, 1"),
20
- UserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
21
- BookId = table.Column<int>(type: "int", nullable: false),
22
- AddedAt = table.Column<DateTime>(type: "datetime", nullable: false, defaultValueSql: "(getdate())")
23
- },
24
- constraints: table =>
25
- {
26
- table.PrimaryKey("PK_WishlistItems", x => x.Id);
27
- table.ForeignKey(
28
- name: "FK_WishlistItems_Books",
29
- column: x => x.BookId,
30
- principalTable: "Books",
31
- principalColumn: "Id",
32
- onDelete: ReferentialAction.Cascade);
33
- table.ForeignKey(
34
- name: "FK_WishlistItems_Users",
35
- column: x => x.UserId,
36
- principalTable: "Users",
37
- principalColumn: "Id",
38
- onDelete: ReferentialAction.Cascade);
39
- });
40
-
41
- migrationBuilder.CreateIndex(
42
- name: "IX_WishlistItems_BookId",
43
- table: "WishlistItems",
44
- column: "BookId");
45
-
46
- migrationBuilder.CreateIndex(
47
- name: "IX_WishlistItems_UserId",
48
- table: "WishlistItems",
49
- column: "UserId");
50
- }
51
-
52
- /// <inheritdoc />
53
- protected override void Down(MigrationBuilder migrationBuilder)
54
- {
55
- migrationBuilder.DropTable(
56
- name: "WishlistItems");
57
- }
58
- }
59
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
DbConnect/Migrations/AppDbContextModelSnapshot.cs DELETED
@@ -1,519 +0,0 @@
1
- // <auto-generated />
2
- using System;
3
- using DbConnect.Data;
4
- using Microsoft.EntityFrameworkCore;
5
- using Microsoft.EntityFrameworkCore.Infrastructure;
6
- using Microsoft.EntityFrameworkCore.Metadata;
7
- using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
8
-
9
- #nullable disable
10
-
11
- namespace DbConnect.Migrations
12
- {
13
- [DbContext(typeof(AppDbContext))]
14
- partial class AppDbContextModelSnapshot : ModelSnapshot
15
- {
16
- protected override void BuildModel(ModelBuilder modelBuilder)
17
- {
18
- #pragma warning disable 612, 618
19
- modelBuilder
20
- .HasAnnotation("ProductVersion", "9.0.0")
21
- .HasAnnotation("Relational:MaxIdentifierLength", 128);
22
-
23
- SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
24
-
25
- modelBuilder.Entity("BookCategory", b =>
26
- {
27
- b.Property<int>("BookId")
28
- .HasColumnType("int");
29
-
30
- b.Property<int>("CategoryId")
31
- .HasColumnType("int");
32
-
33
- b.HasKey("BookId", "CategoryId")
34
- .HasName("PK__BookCate__9C7051A74E7D221D");
35
-
36
- b.HasIndex("CategoryId");
37
-
38
- b.ToTable("BookCategories", (string)null);
39
- });
40
-
41
- modelBuilder.Entity("DbConnect.Entities.Book", b =>
42
- {
43
- b.Property<int>("Id")
44
- .ValueGeneratedOnAdd()
45
- .HasColumnType("int");
46
-
47
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
48
-
49
- b.Property<string>("Author")
50
- .IsRequired()
51
- .HasMaxLength(100)
52
- .HasColumnType("nvarchar(100)");
53
-
54
- b.Property<int>("AvailableCopies")
55
- .ValueGeneratedOnAdd()
56
- .HasColumnType("int")
57
- .HasDefaultValue(1);
58
-
59
- b.Property<string>("CoverUrl")
60
- .HasColumnType("nvarchar(max)");
61
-
62
- b.Property<DateTime>("CreatedAt")
63
- .ValueGeneratedOnAdd()
64
- .HasColumnType("datetime")
65
- .HasDefaultValueSql("(getdate())");
66
-
67
- b.Property<string>("Description")
68
- .HasColumnType("nvarchar(max)");
69
-
70
- b.Property<bool>("IsActive")
71
- .ValueGeneratedOnAdd()
72
- .HasColumnType("bit")
73
- .HasDefaultValue(true);
74
-
75
- b.Property<string>("Isbn")
76
- .IsRequired()
77
- .HasMaxLength(20)
78
- .HasColumnType("nvarchar(20)")
79
- .HasColumnName("ISBN");
80
-
81
- b.Property<string>("Status")
82
- .IsRequired()
83
- .ValueGeneratedOnAdd()
84
- .HasMaxLength(20)
85
- .HasColumnType("nvarchar(20)")
86
- .HasDefaultValue("Available");
87
-
88
- b.Property<string>("Title")
89
- .IsRequired()
90
- .HasMaxLength(200)
91
- .HasColumnType("nvarchar(200)");
92
-
93
- b.Property<int>("TotalCopies")
94
- .ValueGeneratedOnAdd()
95
- .HasColumnType("int")
96
- .HasDefaultValue(1);
97
-
98
- b.Property<DateTime?>("UpdatedAt")
99
- .HasColumnType("datetime");
100
-
101
- b.HasKey("Id")
102
- .HasName("PK__Books__3214EC07AE1974C8");
103
-
104
- b.HasIndex(new[] { "Isbn" }, "UQ__Books__447D36EA79CF66CE")
105
- .IsUnique();
106
-
107
- b.ToTable("Books");
108
- });
109
-
110
- modelBuilder.Entity("DbConnect.Entities.Borrowing", b =>
111
- {
112
- b.Property<Guid>("Id")
113
- .ValueGeneratedOnAdd()
114
- .HasColumnType("uniqueidentifier")
115
- .HasDefaultValueSql("(newid())");
116
-
117
- b.Property<int>("BookId")
118
- .HasColumnType("int");
119
-
120
- b.Property<DateTime>("BorrowDate")
121
- .ValueGeneratedOnAdd()
122
- .HasColumnType("datetime")
123
- .HasDefaultValueSql("(getdate())");
124
-
125
- b.Property<DateTime>("DueDate")
126
- .HasColumnType("datetime");
127
-
128
- b.Property<decimal>("FineAmount")
129
- .HasColumnType("decimal(10, 2)");
130
-
131
- b.Property<bool>("IsFinePaid")
132
- .HasColumnType("bit");
133
-
134
- b.Property<DateTime?>("ReturnDate")
135
- .HasColumnType("datetime");
136
-
137
- b.Property<string>("Status")
138
- .IsRequired()
139
- .ValueGeneratedOnAdd()
140
- .HasMaxLength(20)
141
- .HasColumnType("nvarchar(20)")
142
- .HasDefaultValue("Active");
143
-
144
- b.Property<Guid>("UserId")
145
- .HasColumnType("uniqueidentifier");
146
-
147
- b.HasKey("Id");
148
-
149
- b.HasIndex("BookId");
150
-
151
- b.HasIndex("UserId");
152
-
153
- b.ToTable("Borrowings");
154
- });
155
-
156
- modelBuilder.Entity("DbConnect.Entities.Category", b =>
157
- {
158
- b.Property<int>("Id")
159
- .ValueGeneratedOnAdd()
160
- .HasColumnType("int");
161
-
162
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
163
-
164
- b.Property<string>("Name")
165
- .IsRequired()
166
- .HasMaxLength(100)
167
- .HasColumnType("nvarchar(100)");
168
-
169
- b.HasKey("Id")
170
- .HasName("PK__Categori__3214EC0751B5797D");
171
-
172
- b.HasIndex(new[] { "Name" }, "UQ__Categori__737584F622B16D3A")
173
- .IsUnique();
174
-
175
- b.ToTable("Categories");
176
- });
177
-
178
- modelBuilder.Entity("DbConnect.Entities.Membership", b =>
179
- {
180
- b.Property<int>("Id")
181
- .ValueGeneratedOnAdd()
182
- .HasColumnType("int");
183
-
184
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
185
-
186
- b.Property<int>("BorrowingDays")
187
- .HasColumnType("int");
188
-
189
- b.Property<int>("DurationMonths")
190
- .HasColumnType("int");
191
-
192
- b.Property<int>("MaxBooks")
193
- .HasColumnType("int");
194
-
195
- b.Property<decimal>("Price")
196
- .HasColumnType("decimal(10, 2)");
197
-
198
- b.Property<string>("RewardId")
199
- .HasMaxLength(100)
200
- .HasColumnType("nvarchar(100)");
201
-
202
- b.Property<string>("Type")
203
- .IsRequired()
204
- .HasMaxLength(50)
205
- .HasColumnType("nvarchar(50)");
206
-
207
- b.HasKey("Id")
208
- .HasName("PK__Membersh__3214EC07A6F5A55F");
209
-
210
- b.HasIndex(new[] { "Type" }, "IX_Memberships_Type")
211
- .IsUnique();
212
-
213
- b.ToTable("Memberships");
214
- });
215
-
216
- modelBuilder.Entity("DbConnect.Entities.Notification", b =>
217
- {
218
- b.Property<int>("Id")
219
- .ValueGeneratedOnAdd()
220
- .HasColumnType("int");
221
-
222
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
223
-
224
- b.Property<string>("ActionLink")
225
- .HasMaxLength(500)
226
- .HasColumnType("nvarchar(500)");
227
-
228
- b.Property<string>("ActionText")
229
- .HasMaxLength(100)
230
- .HasColumnType("nvarchar(100)");
231
-
232
- b.Property<DateTime>("CreatedAt")
233
- .ValueGeneratedOnAdd()
234
- .HasColumnType("datetime")
235
- .HasDefaultValueSql("(getdate())");
236
-
237
- b.Property<bool>("IsRead")
238
- .ValueGeneratedOnAdd()
239
- .HasColumnType("bit")
240
- .HasDefaultValue(false);
241
-
242
- b.Property<string>("Message")
243
- .IsRequired()
244
- .HasMaxLength(1000)
245
- .HasColumnType("nvarchar(1000)");
246
-
247
- b.Property<string>("Title")
248
- .IsRequired()
249
- .HasMaxLength(200)
250
- .HasColumnType("nvarchar(200)");
251
-
252
- b.Property<string>("Type")
253
- .IsRequired()
254
- .ValueGeneratedOnAdd()
255
- .HasMaxLength(50)
256
- .HasColumnType("nvarchar(50)")
257
- .HasDefaultValue("Info");
258
-
259
- b.Property<Guid>("UserId")
260
- .HasColumnType("uniqueidentifier");
261
-
262
- b.HasKey("Id");
263
-
264
- b.HasIndex("UserId");
265
-
266
- b.ToTable("Notifications");
267
- });
268
-
269
- modelBuilder.Entity("DbConnect.Entities.User", b =>
270
- {
271
- b.Property<Guid>("Id")
272
- .ValueGeneratedOnAdd()
273
- .HasColumnType("uniqueidentifier")
274
- .HasDefaultValueSql("(newid())");
275
-
276
- b.Property<string>("Address")
277
- .HasMaxLength(255)
278
- .HasColumnType("nvarchar(255)");
279
-
280
- b.Property<bool?>("BanStatus")
281
- .HasColumnType("bit");
282
-
283
- b.Property<DateTime>("CreatedAt")
284
- .ValueGeneratedOnAdd()
285
- .HasColumnType("datetime")
286
- .HasDefaultValueSql("(getdate())");
287
-
288
- b.Property<string>("Email")
289
- .IsRequired()
290
- .HasMaxLength(100)
291
- .HasColumnType("nvarchar(100)");
292
-
293
- b.Property<string>("FcmToken")
294
- .HasMaxLength(500)
295
- .HasColumnType("nvarchar(500)");
296
-
297
- b.Property<string>("FullName")
298
- .IsRequired()
299
- .HasMaxLength(100)
300
- .HasColumnType("nvarchar(100)");
301
-
302
- b.Property<bool>("IsActive")
303
- .ValueGeneratedOnAdd()
304
- .HasColumnType("bit")
305
- .HasDefaultValue(true);
306
-
307
- b.Property<string>("PasswordHash")
308
- .IsRequired()
309
- .HasColumnType("nvarchar(max)");
310
-
311
- b.Property<string>("PhoneNumber")
312
- .HasMaxLength(20)
313
- .HasColumnType("nvarchar(20)");
314
-
315
- b.Property<string>("Role")
316
- .IsRequired()
317
- .ValueGeneratedOnAdd()
318
- .HasMaxLength(20)
319
- .HasColumnType("nvarchar(20)")
320
- .HasDefaultValue("User");
321
-
322
- b.Property<string>("StudentId")
323
- .HasMaxLength(20)
324
- .HasColumnType("nvarchar(20)");
325
-
326
- b.Property<DateTime?>("SuspensionEndDate")
327
- .HasColumnType("datetime");
328
-
329
- b.Property<DateTime?>("UpdatedAt")
330
- .HasColumnType("datetime");
331
-
332
- b.HasKey("Id");
333
-
334
- b.HasIndex(new[] { "Email" }, "UQ_Users_Email")
335
- .IsUnique();
336
-
337
- b.ToTable("Users");
338
- });
339
-
340
- modelBuilder.Entity("DbConnect.Entities.UserSubscription", b =>
341
- {
342
- b.Property<Guid>("Id")
343
- .ValueGeneratedOnAdd()
344
- .HasColumnType("uniqueidentifier")
345
- .HasDefaultValueSql("(newid())");
346
-
347
- b.Property<DateTime>("ExpiryDate")
348
- .HasColumnType("datetime");
349
-
350
- b.Property<string>("ExternalRedemptionId")
351
- .HasMaxLength(100)
352
- .HasColumnType("nvarchar(100)");
353
-
354
- b.Property<bool>("IsActive")
355
- .ValueGeneratedOnAdd()
356
- .HasColumnType("bit")
357
- .HasDefaultValue(true);
358
-
359
- b.Property<int>("MembershipId")
360
- .HasColumnType("int");
361
-
362
- b.Property<DateTime>("StartDate")
363
- .HasColumnType("datetime");
364
-
365
- b.Property<string>("Status")
366
- .IsRequired()
367
- .ValueGeneratedOnAdd()
368
- .HasMaxLength(20)
369
- .HasColumnType("nvarchar(20)")
370
- .HasDefaultValue("Active");
371
-
372
- b.Property<Guid>("UserId")
373
- .HasColumnType("uniqueidentifier");
374
-
375
- b.HasKey("Id");
376
-
377
- b.HasIndex("MembershipId");
378
-
379
- b.HasIndex("UserId");
380
-
381
- b.ToTable("UserSubscriptions");
382
- });
383
-
384
- modelBuilder.Entity("DbConnect.Entities.WishlistItem", b =>
385
- {
386
- b.Property<int>("Id")
387
- .ValueGeneratedOnAdd()
388
- .HasColumnType("int");
389
-
390
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
391
-
392
- b.Property<DateTime>("AddedAt")
393
- .ValueGeneratedOnAdd()
394
- .HasColumnType("datetime")
395
- .HasDefaultValueSql("(getdate())");
396
-
397
- b.Property<int>("BookId")
398
- .HasColumnType("int");
399
-
400
- b.Property<Guid>("UserId")
401
- .HasColumnType("uniqueidentifier");
402
-
403
- b.HasKey("Id");
404
-
405
- b.HasIndex("BookId");
406
-
407
- b.HasIndex("UserId");
408
-
409
- b.ToTable("WishlistItems");
410
- });
411
-
412
- modelBuilder.Entity("BookCategory", b =>
413
- {
414
- b.HasOne("DbConnect.Entities.Book", null)
415
- .WithMany()
416
- .HasForeignKey("BookId")
417
- .OnDelete(DeleteBehavior.Cascade)
418
- .IsRequired()
419
- .HasConstraintName("FK_BookCategories_Books");
420
-
421
- b.HasOne("DbConnect.Entities.Category", null)
422
- .WithMany()
423
- .HasForeignKey("CategoryId")
424
- .OnDelete(DeleteBehavior.Cascade)
425
- .IsRequired()
426
- .HasConstraintName("FK_BookCategories_Categories");
427
- });
428
-
429
- modelBuilder.Entity("DbConnect.Entities.Borrowing", b =>
430
- {
431
- b.HasOne("DbConnect.Entities.Book", "Book")
432
- .WithMany("Borrowings")
433
- .HasForeignKey("BookId")
434
- .IsRequired()
435
- .HasConstraintName("FK_Borrowings_Books");
436
-
437
- b.HasOne("DbConnect.Entities.User", "User")
438
- .WithMany("Borrowings")
439
- .HasForeignKey("UserId")
440
- .IsRequired()
441
- .HasConstraintName("FK_Borrowings_Users");
442
-
443
- b.Navigation("Book");
444
-
445
- b.Navigation("User");
446
- });
447
-
448
- modelBuilder.Entity("DbConnect.Entities.Notification", b =>
449
- {
450
- b.HasOne("DbConnect.Entities.User", "User")
451
- .WithMany()
452
- .HasForeignKey("UserId")
453
- .OnDelete(DeleteBehavior.Cascade)
454
- .IsRequired()
455
- .HasConstraintName("FK_Notifications_Users");
456
-
457
- b.Navigation("User");
458
- });
459
-
460
- modelBuilder.Entity("DbConnect.Entities.UserSubscription", b =>
461
- {
462
- b.HasOne("DbConnect.Entities.Membership", "Membership")
463
- .WithMany("UserSubscriptions")
464
- .HasForeignKey("MembershipId")
465
- .IsRequired()
466
- .HasConstraintName("FK_UserSubscriptions_Memberships");
467
-
468
- b.HasOne("DbConnect.Entities.User", "User")
469
- .WithMany("UserSubscriptions")
470
- .HasForeignKey("UserId")
471
- .IsRequired()
472
- .HasConstraintName("FK_UserSubscriptions_Users");
473
-
474
- b.Navigation("Membership");
475
-
476
- b.Navigation("User");
477
- });
478
-
479
- modelBuilder.Entity("DbConnect.Entities.WishlistItem", b =>
480
- {
481
- b.HasOne("DbConnect.Entities.Book", "Book")
482
- .WithMany()
483
- .HasForeignKey("BookId")
484
- .OnDelete(DeleteBehavior.Cascade)
485
- .IsRequired()
486
- .HasConstraintName("FK_WishlistItems_Books");
487
-
488
- b.HasOne("DbConnect.Entities.User", "User")
489
- .WithMany()
490
- .HasForeignKey("UserId")
491
- .OnDelete(DeleteBehavior.Cascade)
492
- .IsRequired()
493
- .HasConstraintName("FK_WishlistItems_Users");
494
-
495
- b.Navigation("Book");
496
-
497
- b.Navigation("User");
498
- });
499
-
500
- modelBuilder.Entity("DbConnect.Entities.Book", b =>
501
- {
502
- b.Navigation("Borrowings");
503
- });
504
-
505
- modelBuilder.Entity("DbConnect.Entities.Membership", b =>
506
- {
507
- b.Navigation("UserSubscriptions");
508
- });
509
-
510
- modelBuilder.Entity("DbConnect.Entities.User", b =>
511
- {
512
- b.Navigation("Borrowings");
513
-
514
- b.Navigation("UserSubscriptions");
515
- });
516
- #pragma warning restore 612, 618
517
- }
518
- }
519
- }