From 66b64e54c2948e8ff9c4618f0a941e55c6b350d2 Mon Sep 17 00:00:00 2001 From: Mehrdad Shirvani Date: Fri, 18 Jul 2025 12:52:01 +0330 Subject: [PATCH] refactor: clean session07 notes --- .../Session07/Session07 Backend.md | 40 +++++++++++++------ .../Session07/Session07 Frontend.md | 1 - 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/ProjectOrientedSessions/Session07/Session07 Backend.md b/ProjectOrientedSessions/Session07/Session07 Backend.md index 92094e0..a696172 100644 --- a/ProjectOrientedSessions/Session07/Session07 Backend.md +++ b/ProjectOrientedSessions/Session07/Session07 Backend.md @@ -1,12 +1,31 @@ -# Add a field in Database + +# 🛠️ Task Checklist +## 🚧 Branching + +- [ ] Create the `feature/[name]` branch from `develop` + +## Task +- [ ] Task +📂 Suggested Folder: `Domain/Framework/Interfaces/Respositories` +# 🧠 Hints & Notes +# 🙌 Acknowledgements + +- ChatGPT for snippet refinement and explanations +# 🔍 References + + + +This file +--- +## Add a field in Database - [ ] Add `User` field in `Roles` table using SSMS or Seed data in DbContext file - [ ] Make sure the property `PersonId` is nullable in `Account`, so you can add fields related to "Person" later after registration -# Branching +## Branching - [ ] Create the feature/authentication branch based on develop -# Adjusting Account and Configurations +## Adjusting Account and Configurations - [ ] Add navigation property for `AccountRoles` in Account ```c# @@ -32,9 +51,9 @@ builder.HasOne(ar => ar.Role) .OnDelete(DeleteBehavior.Restrict); ``` -# Creating DTOs +## Creating DTOs 📂 Suggested Folder: ApplicationLayer/DTOs/[RelatedFolder] -## AccountDto +### AccountDto - [ ] Create `AccountDto` to expose relevant account information: ```c# public class AccountDto @@ -47,7 +66,7 @@ public class AccountDto public List Roles { get; set; } } ``` -## AuthResponseDto +### AuthResponseDto - [ ] Define a DTO for authentication responses: ```c# public class AuthResponseDto @@ -66,7 +85,7 @@ public class LoginRequestDto public string Password { get; set; } = null!; } ``` -## RegisterRequestDto +### RegisterRequestDto - [ ] Define a DTO for registration with validation attributes: ```c# public class RegisterRequestDto @@ -135,10 +154,8 @@ Frontend validation is for **user experience**, not security. ✅ **Both.** -- **Frontend**: show real-time UX feedback (“Password must be 6+ characters”). - +- **Frontend**: show real-time UX feedback (“Password must be 6+ characters”). - **Backend**: enforce security. - **Backend is the source of truth.** Frontend can be bypassed (e.g., Postman). @@ -146,9 +163,7 @@ Frontend can be bypassed (e.g., Postman). In the backend, you can either: - Use annotations like `[MinLength(6)]` - - Or do manual checks: - ```csharp if (dto.Password.Length < 6) @@ -173,7 +188,6 @@ But again: if someone sends malformed input manually (e.g., via Postman), backen 💡 **Best practice:** - Validate `ConfirmPassword` in frontend (UX) - - Do one last check in backend, or use `[Compare]` for auto-validation diff --git a/ProjectOrientedSessions/Session07/Session07 Frontend.md b/ProjectOrientedSessions/Session07/Session07 Frontend.md index d1d48ca..208003c 100644 --- a/ProjectOrientedSessions/Session07/Session07 Frontend.md +++ b/ProjectOrientedSessions/Session07/Session07 Frontend.md @@ -1,4 +1,3 @@ - # Branching - [ ] Create the feature/authentication branch based on develop