Ignore:
Timestamp:
12/08/25 21:51:12 (10 months ago)
Author:
Stefan-Saveski <stefan@…>
Branches:
master
Children:
bb656bc
Parents:
a92a2a4
Message:

Refactor and enhance application structure

Enhanced error handling in AuthController with detailed exception handling for user registration. Updated UserDTO to improve JSON serialization and renamed enums for clarity. Introduced new entities (Major, PassedSubject, etc.) and seeded initial data in AppDbContext.

Replaced legacy migrations with 20251208203846_InitialCreate, reflecting the updated schema. Fixed typographical errors and improved JSON serialization in Program.cs with case-insensitive property matching and enum handling.

Refactored repository interfaces for better null safety. Improved debugging in AuthService and updated connection strings. Added the PassedSubject entity and cleaned up redundant code and unused imports for better maintainability.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • iknow-api/Controllers/AuthController.cs

    ra92a2a4 rc2f79d7  
    3737        public async Task<IActionResult> Register([FromBody] RegisterDto request)
    3838        {
    39             var result = await _authService.RegisterAsync(request);
    40             if (!result) return BadRequest("User already exists");
    41             return Ok("User registered successfully");
     39            //Console.WriteLine(request);
     40
     41            try
     42            {
     43                var result = await _authService.RegisterAsync(request);
     44                return Ok("User registered successfully");
     45            }
     46            catch (InvalidOperationException ex)
     47            {
     48                return BadRequest(new { message = ex.Message });
     49            }
     50            catch (Exception ex)
     51            {
     52                return StatusCode(500, new { message = "An error occurred during registration", error = ex.Message });
     53            }
    4254        }
    4355
     
    6577            { return BadRequest(new { message = "No token found!" }); }
    6678        }
     79
    6780    }
    6881}
Note: See TracChangeset for help on using the changeset viewer.