Changes in / [ff202cf:c2e73b6]
- Location:
- iknow-api
- Files:
-
- 10 deleted
- 8 edited
-
Controllers/UserController.cs (deleted)
-
DTOs/UserDTO.cs (modified) (3 diffs)
-
Data/AppDbContext.cs (modified) (1 diff)
-
Migrations/20251027140655_InitialCreate.Designer.cs (deleted)
-
Migrations/20251027140655_InitialCreate.cs (deleted)
-
Migrations/20251027191028_dbRelations.Designer.cs (deleted)
-
Migrations/20251027191028_dbRelations.cs (deleted)
-
Migrations/AppDbContextModelSnapshot.cs (modified) (4 diffs)
-
Models/ContactInfo.cs (deleted)
-
Models/EnrollmentInfo.cs (deleted)
-
Models/HighSchool.cs (deleted)
-
Models/User.cs (modified) (1 diff)
-
Program.cs (modified) (3 diffs)
-
Repository/Implementations/UserRepository.cs (modified) (2 diffs)
-
Repository/Interface/IUserRepository.cs (modified) (1 diff)
-
Services/Implementations/AuthService.cs (modified) (1 diff)
-
Services/Implementations/UserService.cs (deleted)
-
Services/Interfaces/IUserService.cs (deleted)
Legend:
- Unmodified
- Added
- Removed
-
iknow-api/DTOs/UserDTO.cs
rff202cf rc2e73b6 7 7 public string Password { get; set; } = string.Empty; 8 8 public bool GenerateRefreshToken { get; set; } 9 }10 public class GetUserDataDto11 {12 public string JWT { get; set; }13 9 } 14 10 … … 23 19 public DateTime Bday { get; set; } 24 20 public UserRole Role { get; set; } 25 public float gpa { get; set; }26 public type tip { get; set; }27 public string city { get; set; } = string.Empty;28 public string address { get; set; } = string.Empty;29 public string municipality { get; set; } = string.Empty;30 public string phoneNumber { get; set; } = string.Empty;31 public string microsoftEmail { get; set; } = string.Empty;32 public int enrollmentYear { get; set; }33 public quota quotaType { get; set; }34 public major majorType { get; set; }35 36 21 } 37 22 … … 56 41 Student 57 42 } 58 public enum type59 {60 strucen, gimnazija61 }62 public enum quota63 {64 drzavna, privatna, stipendija65 }66 public enum major67 {68 SIIS, PIT, KN, KI, IMB, IE, SSP, SEIS69 }70 43 } -
iknow-api/Data/AppDbContext.cs
rff202cf rc2e73b6 10 10 11 11 public DbSet<User> User { get; set; } 12 public DbSet<ContactInfo> ContactInfo { get; set; }13 public DbSet<HighSchool> HighSchool { get; set; }14 public DbSet<EnrollmentInfo> EnrollmentInfo { get; set; }15 12 public DbSet<RefreshToken> RefreshToken { get; set; } 16 13 } -
iknow-api/Migrations/AppDbContextModelSnapshot.cs
rff202cf rc2e73b6 23 23 NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); 24 24 25 modelBuilder.Entity("iknow_api.Models.ContactInfo", b =>26 25 modelBuilder.Entity("iknow_api.Models.RefreshToken", b => 27 26 { … … 32 31 NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); 33 32 34 b.Property<int>("UserId")35 .HasColumnType("integer");36 37 b.Property<string>("address")38 .HasColumnType("text");39 40 b.Property<string>("city")41 .HasColumnType("text");42 43 b.Property<string>("microsoftEmail")44 .HasColumnType("text");45 46 b.Property<string>("municipality")47 .HasColumnType("text");48 49 b.Property<string>("phoneNumber")50 .HasColumnType("text");51 52 b.HasKey("Id");53 54 b.HasIndex("UserId")55 .IsUnique();56 57 b.ToTable("ContactInfo");58 });59 60 modelBuilder.Entity("iknow_api.Models.EnrollmentInfo", b =>61 {62 b.Property<int>("Id")63 .ValueGeneratedOnAdd()64 .HasColumnType("integer");65 66 NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));67 68 b.Property<int>("UserId")69 .HasColumnType("integer");70 71 b.Property<int>("enrollmentYear")72 .HasColumnType("integer");73 74 b.Property<int>("major")75 .HasColumnType("integer");76 77 b.HasKey("Id");78 79 b.HasIndex("UserId")80 .IsUnique();81 82 b.ToTable("EnrollmentInfo");83 });84 85 modelBuilder.Entity("iknow_api.Models.HighSchool", b =>86 {87 b.Property<int>("Id")88 .ValueGeneratedOnAdd()89 .HasColumnType("integer");90 91 NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));92 93 b.Property<float>("GPA")94 .HasColumnType("real");95 96 b.Property<int>("UserId")97 .HasColumnType("integer");98 99 b.Property<int>("tip")100 .HasColumnType("integer");101 102 b.HasKey("Id");103 104 b.HasIndex("UserId")105 .IsUnique();106 107 b.ToTable("HighSchool");108 33 b.Property<DateTime>("ExpiresAt") 109 34 .HasColumnType("timestamp with time zone"); … … 163 88 }); 164 89 165 modelBuilder.Entity("iknow_api.Models.ContactInfo", b =>166 {167 b.HasOne("iknow_api.Models.User", "User")168 .WithOne("ContactInfo")169 .HasForeignKey("iknow_api.Models.ContactInfo", "UserId")170 90 modelBuilder.Entity("iknow_api.Models.RefreshToken", b => 171 91 { … … 178 98 b.Navigation("User"); 179 99 }); 180 181 modelBuilder.Entity("iknow_api.Models.EnrollmentInfo", b =>182 {183 b.HasOne("iknow_api.Models.User", "User")184 .WithOne("EnrollmentInfo")185 .HasForeignKey("iknow_api.Models.EnrollmentInfo", "UserId")186 .OnDelete(DeleteBehavior.Cascade)187 .IsRequired();188 189 b.Navigation("User");190 });191 192 modelBuilder.Entity("iknow_api.Models.HighSchool", b =>193 {194 b.HasOne("iknow_api.Models.User", "User")195 .WithOne("HighSchool")196 .HasForeignKey("iknow_api.Models.HighSchool", "UserId")197 .OnDelete(DeleteBehavior.Cascade)198 .IsRequired();199 200 b.Navigation("User");201 });202 203 modelBuilder.Entity("iknow_api.Models.User", b =>204 {205 b.Navigation("ContactInfo");206 207 b.Navigation("EnrollmentInfo");208 209 b.Navigation("HighSchool");210 });211 100 #pragma warning restore 612, 618 212 101 } -
iknow-api/Models/User.cs
rff202cf rc2e73b6 21 21 public DateTime CreatedAt { get; set; } 22 22 public UserRole Role { get; set; } 23 public HighSchool? HighSchool { get; set; }24 public ContactInfo? ContactInfo { get; set; }25 public EnrollmentInfo? EnrollmentInfo { get; set; }26 23 27 24 } -
iknow-api/Program.cs
rff202cf rc2e73b6 1 1 using System.Text; 2 using System.Text.Json.Serialization;3 2 using iknow_api.Data; 4 3 using iknow_api.Repositories; … … 34 33 }); 35 34 // Add services to the container. 36 builder.Services.AddControllers() 37 .AddJsonOptions(options => 38 { 39 options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles; 40 }); 35 builder.Services.AddControllers(); 41 36 builder.Services.AddOpenApi(); 42 37 … … 47 42 // Register your services 48 43 builder.Services.AddScoped<IAuthService, AuthService>(); 49 builder.Services.AddScoped<IUserRepository, UserRepository>(); // You'll need to add the UserRepository implementation50 builder.Services.AddScoped<IUserService, UserService>();51 52 44 builder.Services.AddScoped<IRefreshTokenService, RefreshTokenService>(); 53 45 builder.Services.AddScoped<IUserRepository, UserRepository>(); -
iknow-api/Repository/Implementations/UserRepository.cs
rff202cf rc2e73b6 24 24 return await _context.User.FirstOrDefaultAsync(u => u.Email == username); 25 25 } 26 27 public async Task<User?> GetUserByIdAsync(int id)28 {29 return await _context.User30 .Include(u => u.ContactInfo)31 .Include(u => u.EnrollmentInfo)32 .Include(u => u.HighSchool)33 .FirstOrDefaultAsync(u => u.Id == id);34 }35 36 37 26 public async Task<User?> GetOnlyUserByIdAsync(int id) 38 27 { … … 44 33 await _context.SaveChangesAsync(); 45 34 } 46 public async Task AddContactAsync(ContactInfo contactInfo)47 {48 _context.ContactInfo.Add(contactInfo);49 await _context.SaveChangesAsync();50 }51 public async Task AddEnrollmentAsync(EnrollmentInfo enrollment)52 {53 _context.EnrollmentInfo.Add(enrollment);54 await _context.SaveChangesAsync();55 }56 public async Task AddHighSchoolAsync(HighSchool highSchool)57 {58 _context.HighSchool.Add(highSchool);59 await _context.SaveChangesAsync();60 }61 35 62 36 public async Task<int> GetUsersCountAsync() -
iknow-api/Repository/Interface/IUserRepository.cs
rff202cf rc2e73b6 7 7 Task<User?> GetUserByUsernameAsync(string username); 8 8 Task AddUserAsync(User user); 9 Task AddContactAsync(ContactInfo contactInfo);10 Task AddEnrollmentAsync(EnrollmentInfo enrollment);11 Task AddHighSchoolAsync(HighSchool highSchool);12 9 Task<int> GetUsersCountAsync(); 13 Task<User> GetUserByIdAsync(int id);14 10 Task<User?> GetOnlyUserByIdAsync(int id); 15 11 -
iknow-api/Services/Implementations/AuthService.cs
rff202cf rc2e73b6 45 45 46 46 await _userRepository.AddUserAsync(user); 47 int userId = user.Id;48 var contactInfo = new ContactInfo49 {50 UserId = userId,51 city = registerDto.city,52 address = registerDto.address,53 municipality = registerDto.municipality,54 phoneNumber = registerDto.phoneNumber,55 microsoftEmail = registerDto.microsoftEmail56 };57 await _userRepository.AddContactAsync(contactInfo);58 var enrollmentInfo = new EnrollmentInfo59 {60 UserId = userId,61 enrollmentYear = registerDto.enrollmentYear,62 quota = (Models.quota)registerDto.quotaType,63 major = (Models.major)registerDto.majorType64 };65 await _userRepository.AddEnrollmentAsync(enrollmentInfo);66 await _userRepository.AddHighSchoolAsync(new HighSchool67 {68 UserId = userId,69 GPA = registerDto.gpa,70 tip = (Models.type)registerDto.tip71 });72 47 return true; 73 48 }
Note:
See TracChangeset
for help on using the changeset viewer.
