From 4b1ee6d2caef59a9fb3d9a2737db606084b59ccc Mon Sep 17 00:00:00 2001 From: Johan Reitan Date: Thu, 18 Sep 2025 13:28:19 +0200 Subject: [PATCH] cleanedUpSeeder + made one endpoint --- api.tests/Notes/GetNotesTests.cs | 1 - .../UserEndpointTests/UpdateUserTests.cs | 4 +-- api.tests/api.tests.csproj | 18 ++++++---- exercise.wwwapi/DTOs/Notes/NoteDTO.cs | 16 ++++++++- exercise.wwwapi/DTOs/UserDTO.cs | 25 +++++++++++++- exercise.wwwapi/Data/ModelSeeder.cs | 15 +++++---- exercise.wwwapi/Endpoints/UserEndpoints.cs | 33 +++++++------------ exercise.wwwapi/Models/Cohort.cs | 5 +-- exercise.wwwapi/Models/Cohort_Course.cs | 29 ---------------- exercise.wwwapi/Models/Comment.cs | 5 +-- exercise.wwwapi/Models/Course.cs | 4 +-- exercise.wwwapi/Models/CourseModule.cs | 3 +- exercise.wwwapi/Models/Exercise.cs | 5 +-- exercise.wwwapi/Models/Like.cs | 4 +-- exercise.wwwapi/Models/Module.cs | 5 +-- exercise.wwwapi/Models/Note.cs | 5 +-- exercise.wwwapi/Models/Post.cs | 5 +-- exercise.wwwapi/Models/Unit.cs | 5 +-- exercise.wwwapi/Models/User.cs | 33 ++++++++++--------- exercise.wwwapi/Models/UserCC.cs | 10 +++--- exercise.wwwapi/Models/UserExercise.cs | 3 +- exercise.wwwapi/Program.cs | 1 + exercise.wwwapi/Repository/IRepository.cs | 4 ++- exercise.wwwapi/Repository/Repository.cs | 15 ++++++++- .../UserValidators/UserUpdateValidator.cs | 2 +- exercise.wwwapi/exercise.wwwapi.csproj | 20 +++++------ 26 files changed, 154 insertions(+), 121 deletions(-) delete mode 100644 exercise.wwwapi/Models/Cohort_Course.cs diff --git a/api.tests/Notes/GetNotesTests.cs b/api.tests/Notes/GetNotesTests.cs index 3b4f045..3c01df7 100644 --- a/api.tests/Notes/GetNotesTests.cs +++ b/api.tests/Notes/GetNotesTests.cs @@ -3,7 +3,6 @@ using exercise.wwwapi.DTOs.Notes; using exercise.wwwapi.Endpoints; using exercise.wwwapi.Models; -using exercise.wwwapi.Models.UserInfo; using System; using System.Collections.Generic; using System.Linq; diff --git a/api.tests/UserEndpointTests/UpdateUserTests.cs b/api.tests/UserEndpointTests/UpdateUserTests.cs index df3b06d..512bb55 100644 --- a/api.tests/UserEndpointTests/UpdateUserTests.cs +++ b/api.tests/UserEndpointTests/UpdateUserTests.cs @@ -154,7 +154,7 @@ public async Task UpdateUserMobileNumberValidationFailsTest() _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", result.Data.Token); var updateUser = new UpdateUserRequestDTO { - Phone = phone, + Mobile = phone, }; var content = new StringContent( JsonSerializer.Serialize(updateUser), @@ -328,7 +328,7 @@ public async Task UpdateUserMobileValidationPassesTest() _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", result.Data.Token); var updateUser = new UpdateUserRequestDTO { - Phone = phone, + Mobile = phone, Username = username, }; var content = new StringContent( diff --git a/api.tests/api.tests.csproj b/api.tests/api.tests.csproj index 13f115a..bb9ac3d 100644 --- a/api.tests/api.tests.csproj +++ b/api.tests/api.tests.csproj @@ -9,12 +9,18 @@ - - - - - - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + diff --git a/exercise.wwwapi/DTOs/Notes/NoteDTO.cs b/exercise.wwwapi/DTOs/Notes/NoteDTO.cs index 9a10a9b..57573f0 100644 --- a/exercise.wwwapi/DTOs/Notes/NoteDTO.cs +++ b/exercise.wwwapi/DTOs/Notes/NoteDTO.cs @@ -1,4 +1,5 @@ -using System.ComponentModel.DataAnnotations; +using exercise.wwwapi.Models; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json.Serialization; @@ -20,5 +21,18 @@ public class NoteDTO [JsonPropertyName("updatedat")] public DateTime UpdatedAt { get; set; } + public NoteDTO() + { + + } + public NoteDTO(Note model) + { + Id = model.Id; + Title = model.Title; + Content = model.Content; + CreatedAt = model.CreatedAt; + UpdatedAt = model.UpdatedAt; + + } } } diff --git a/exercise.wwwapi/DTOs/UserDTO.cs b/exercise.wwwapi/DTOs/UserDTO.cs index e0d483f..e77ab7b 100644 --- a/exercise.wwwapi/DTOs/UserDTO.cs +++ b/exercise.wwwapi/DTOs/UserDTO.cs @@ -36,7 +36,30 @@ public class UserDTO public Specialism? Specialism { get; set; } [JsonPropertyName("notes")] - public ICollection Notes { get; set; } + + public ICollection Notes { get; set; } = new List(); [JsonPropertyName("role")] public string Role { get; set; } + + public UserDTO() + { + + } + + public UserDTO(User model) + { + Id = model.Id; + Email = model.Email; + FirstName = model.FirstName; + LastName = model.LastName; + Bio = model.Bio; + Github = model.Github; + Username = model.Username; + Mobile = model.Mobile; + Specialism = model.Specialism; + Role = model.Role.ToString(); + Notes = []; + + + } } \ No newline at end of file diff --git a/exercise.wwwapi/Data/ModelSeeder.cs b/exercise.wwwapi/Data/ModelSeeder.cs index 02b488a..023de14 100644 --- a/exercise.wwwapi/Data/ModelSeeder.cs +++ b/exercise.wwwapi/Data/ModelSeeder.cs @@ -31,10 +31,10 @@ public static void Seed(ModelBuilder modelBuilder) SeedExercises(ref modelBuilder); SeedNotes(ref modelBuilder); - SeedCohortCourses(ref modelBuilder); SeedCourseModules(ref modelBuilder); - SeedUserCC(ref modelBuilder); SeedUserExercises(ref modelBuilder); + SeedCohortCourses(ref modelBuilder); + SeedUserCC(ref modelBuilder); } @@ -56,7 +56,8 @@ private static void SeedUsers(ref ModelBuilder modelBuilder) Mobile = "1234567890", Github = "", Bio = "", - Specialism = Specialism.Frontend + Specialism = Specialism.Frontend, + PhotoUrl = "" }, new User { @@ -70,7 +71,8 @@ private static void SeedUsers(ref ModelBuilder modelBuilder) Mobile = "1234123", Github = "", Bio = "", - Specialism = Specialism.Backend + Specialism = Specialism.Backend, + PhotoUrl = "" }, new User { @@ -84,7 +86,8 @@ private static void SeedUsers(ref ModelBuilder modelBuilder) Mobile = "55555555", Github = "", Bio = "", - Specialism = Specialism.Frontend + Specialism = Specialism.Frontend, + PhotoUrl = "" } ); @@ -310,7 +313,7 @@ private static void SeedUserCC(ref ModelBuilder modelBuilder) private static void SeedUserExercises(ref ModelBuilder modelBuilder) { - modelBuilder.Entity().HasData( + modelBuilder.Entity().HasData( new UserExercise { Id = 1, diff --git a/exercise.wwwapi/Endpoints/UserEndpoints.cs b/exercise.wwwapi/Endpoints/UserEndpoints.cs index 76b4efe..e61e4b2 100644 --- a/exercise.wwwapi/Endpoints/UserEndpoints.cs +++ b/exercise.wwwapi/Endpoints/UserEndpoints.cs @@ -19,6 +19,7 @@ using System.Diagnostics; using exercise.wwwapi.Models; using exercise.wwwapi.Factories; +using Microsoft.EntityFrameworkCore; namespace exercise.wwwapi.EndPoints; @@ -30,7 +31,7 @@ public static void ConfigureAuthApi(this WebApplication app) { var users = app.MapGroup("users"); users.MapPost("/", Register).WithSummary("Create user"); - users.MapGet("/by_cohort/{id}", GetUsersByCohort).WithSummary("Get all users from a cohort"); + users.MapGet("/by_cohort/{id}", GetUsersByCohortCourse).WithSummary("Get all users from a cohort"); users.MapGet("/", GetUsers).WithSummary("Get all users or filter by first name, last name or full name"); users.MapGet("/{id}", GetUserById).WithSummary("Get user by user id"); app.MapPost("/login", Login).WithSummary("Localhost Login"); @@ -68,28 +69,18 @@ private static async Task GetUsers(IRepository userRepository, st }; return TypedResults.Ok(response); } + [ProducesResponseType(StatusCodes.Status200OK)] - private static async Task GetUsersByCohort(IRepository userRepository, int id, ClaimsPrincipal claimsPrincipal) + private static async Task GetUsersByCohortCourse(IRepository ccRepository, int cc_id, ClaimsPrincipal claimsPrincipal) { - var all = await userRepository.GetAllAsync(u => u.Notes); - var results = all.Where(u => u.CohortId == id).ToList(); + var response = await ccRepository.GetByIdWithIncludes(a => a.Include(b => b.UserCCs).ThenInclude(a => a.User), cc_id); - var userRole = claimsPrincipal.Role(); - var authorizedAsTeacher = AuthorizeTeacher(claimsPrincipal); + var results = response.UserCCs.Select(a => a.User).ToList(); + var dto_results = results.Select(a => new UserDTO(a)); + + + return TypedResults.Ok(dto_results); - var userData = new UsersSuccessDTO - { - Users = results.Select(user => authorizedAsTeacher - ? UserFactory.GetUserDTO(user, PrivilegeLevel.Teacher) - : UserFactory.GetUserDTO(user, PrivilegeLevel.Student)) - .ToList() - }; - var response = new ResponseDTO - { - Status = "success", - Data = userData - }; - return TypedResults.Ok(response); } [ProducesResponseType(StatusCodes.Status200OK)] @@ -350,8 +341,8 @@ public static async Task UpdateUser(IRepository userRepository, i Github = user.Github, Username = user.Username, Mobile = user.Mobile, - Specialism = user.Specialism, - Role = user.Role, + Specialism = (Specialism)user.Specialism, + Role = (Role)user.Role, } }; diff --git a/exercise.wwwapi/Models/Cohort.cs b/exercise.wwwapi/Models/Cohort.cs index 1c25612..72efbfc 100644 --- a/exercise.wwwapi/Models/Cohort.cs +++ b/exercise.wwwapi/Models/Cohort.cs @@ -1,10 +1,11 @@ -using System.ComponentModel.DataAnnotations; +using exercise.wwwapi.Repository; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace exercise.wwwapi.Models; [Table("cohorts")] -public class Cohort +public class Cohort : IEntity { [Key] [Column("id")] diff --git a/exercise.wwwapi/Models/Cohort_Course.cs b/exercise.wwwapi/Models/Cohort_Course.cs deleted file mode 100644 index dd90613..0000000 --- a/exercise.wwwapi/Models/Cohort_Course.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using exercise.wwwapi.Models.UserInfo; - - -namespace exercise.wwwapi.Models -{ - [Table("cohort_course")] - public class CohortCourse - { - [Key] - [Column("id")] - public int Id { get; set; } - - [ForeignKey(nameof(Cohort))] - [Column("cohort_id")] - public int CohortId { get; set; } - - [ForeignKey(nameof(Course))] - [Column("course_id")] - public int CourseId { get; set; } - - public Cohort Cohort { get; set; } - public Course Course { get; set; } - - - - } -} diff --git a/exercise.wwwapi/Models/Comment.cs b/exercise.wwwapi/Models/Comment.cs index 35b9f86..fadc1ab 100644 --- a/exercise.wwwapi/Models/Comment.cs +++ b/exercise.wwwapi/Models/Comment.cs @@ -1,11 +1,12 @@ -using System.ComponentModel.DataAnnotations; +using exercise.wwwapi.Repository; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json.Serialization; namespace exercise.wwwapi.Models; [Table("comments")] -public class Comment +public class Comment : IEntity { [Key] [Column("id")] diff --git a/exercise.wwwapi/Models/Course.cs b/exercise.wwwapi/Models/Course.cs index ff84e41..cab9bb7 100644 --- a/exercise.wwwapi/Models/Course.cs +++ b/exercise.wwwapi/Models/Course.cs @@ -1,11 +1,11 @@ -using exercise.wwwapi.Models.UserInfo; +using exercise.wwwapi.Repository; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace exercise.wwwapi.Models; [Table("courses")] -public class Course +public class Course : IEntity { [Key] [Column("id")] diff --git a/exercise.wwwapi/Models/CourseModule.cs b/exercise.wwwapi/Models/CourseModule.cs index 09ce154..2ceb090 100644 --- a/exercise.wwwapi/Models/CourseModule.cs +++ b/exercise.wwwapi/Models/CourseModule.cs @@ -1,4 +1,5 @@ using exercise.wwwapi.Enums; +using exercise.wwwapi.Repository; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json.Serialization; @@ -6,7 +7,7 @@ namespace exercise.wwwapi.Models; [Table("Course_Module")] -public class CourseModule +public class CourseModule : IEntity { [Key] [Column("id")] diff --git a/exercise.wwwapi/Models/Exercise.cs b/exercise.wwwapi/Models/Exercise.cs index dc0a47f..6624f46 100644 --- a/exercise.wwwapi/Models/Exercise.cs +++ b/exercise.wwwapi/Models/Exercise.cs @@ -1,10 +1,11 @@ -using System.ComponentModel.DataAnnotations; +using exercise.wwwapi.Repository; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace exercise.wwwapi.Models; [Table("exercise")] -public class Exercise +public class Exercise : IEntity { [Key] [Column("id")] diff --git a/exercise.wwwapi/Models/Like.cs b/exercise.wwwapi/Models/Like.cs index 02e930e..3966bda 100644 --- a/exercise.wwwapi/Models/Like.cs +++ b/exercise.wwwapi/Models/Like.cs @@ -1,11 +1,11 @@ -using exercise.wwwapi.Models.UserInfo; +using exercise.wwwapi.Repository; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace exercise.wwwapi.Models { [Table("Likes")] - public class Like + public class Like : IEntity { [Key] [Column("id")] diff --git a/exercise.wwwapi/Models/Module.cs b/exercise.wwwapi/Models/Module.cs index f275621..7016ae4 100644 --- a/exercise.wwwapi/Models/Module.cs +++ b/exercise.wwwapi/Models/Module.cs @@ -1,10 +1,11 @@ -using System.ComponentModel.DataAnnotations; +using exercise.wwwapi.Repository; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace exercise.wwwapi.Models; [Table("modules")] -public class Module +public class Module : IEntity { [Key] [Column("id")] diff --git a/exercise.wwwapi/Models/Note.cs b/exercise.wwwapi/Models/Note.cs index 883246f..d600116 100644 --- a/exercise.wwwapi/Models/Note.cs +++ b/exercise.wwwapi/Models/Note.cs @@ -1,11 +1,12 @@ -using System.ComponentModel.DataAnnotations; +using exercise.wwwapi.Repository; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json.Serialization; namespace exercise.wwwapi.Models { [Table("notes")] - public class Note + public class Note : IEntity { [Key] [Column("id")] diff --git a/exercise.wwwapi/Models/Post.cs b/exercise.wwwapi/Models/Post.cs index ccc5f9e..3be3e0c 100644 --- a/exercise.wwwapi/Models/Post.cs +++ b/exercise.wwwapi/Models/Post.cs @@ -1,11 +1,12 @@ -using System.ComponentModel.DataAnnotations; +using exercise.wwwapi.Repository; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json.Serialization; namespace exercise.wwwapi.Models; [Table("posts")] -public class Post +public class Post : IEntity { [Key] [Column("id")] diff --git a/exercise.wwwapi/Models/Unit.cs b/exercise.wwwapi/Models/Unit.cs index 801d6c2..701a343 100644 --- a/exercise.wwwapi/Models/Unit.cs +++ b/exercise.wwwapi/Models/Unit.cs @@ -1,10 +1,11 @@ -using System.ComponentModel.DataAnnotations; +using exercise.wwwapi.Repository; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace exercise.wwwapi.Models; [Table("units")] -public class Unit +public class Unit : IEntity { [Key] [Column("id")] diff --git a/exercise.wwwapi/Models/User.cs b/exercise.wwwapi/Models/User.cs index 59c14be..6c6d3fc 100644 --- a/exercise.wwwapi/Models/User.cs +++ b/exercise.wwwapi/Models/User.cs @@ -1,4 +1,5 @@ using exercise.wwwapi.Enums; +using exercise.wwwapi.Repository; using Microsoft.EntityFrameworkCore; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; @@ -8,8 +9,8 @@ namespace exercise.wwwapi.Models; [Table("users")] [Index(nameof(Email), IsUnique = true)] [Index(nameof(Username), IsUnique = true)] -public class User - { +public class User : IEntity +{ [Key] [Column ("id")] public int Id { get; set; } @@ -23,27 +24,27 @@ public class User [Column ("password_hash", TypeName = "varchar(100)")] public string PasswordHash { get; set; } [Column ("role")] - public Role Role { get; set; } + public Role? Role { get; set; } [Column ("first_name", TypeName = "varchar(100)")] - public string FirstName { get; set; } + public string? FirstName { get; set; } [Column ("last_name", TypeName = "varchar(100)")] - public string LastName { get; set; } + public string? LastName { get; set; } [Column ("mobile", TypeName = "varchar(100)")] - public string Mobile { get; set; } + public string? Mobile { get; set; } [Column ("github", TypeName = "varchar(100)")] - public string Github { get; set; } + public string? Github { get; set; } [Column ("bio", TypeName = "varchar(100)")] - public string Bio { get; set; } + public string? Bio { get; set; } [Column ("photo_url", TypeName = "varchar(100)")] - public string PhotoUrl { get; set; } + public string? PhotoUrl { get; set; } [Column ("specialism")] - public Specialism Specialism { get; set; } - public ICollection Posts { get; set; } - public ICollection Likes { get; set; } - public ICollection Comments { get; set; } - public ICollection Notes { get; set; } - public ICollection User_Exercises { get; set; } - public ICollection User_CC { get; set; } + public Specialism? Specialism { get; set; } + public ICollection? Posts { get; set; } + public ICollection? Likes { get; set; } + public ICollection? Comments { get; set; } + public ICollection? Notes { get; set; } + public ICollection? User_Exercises { get; set; } + public ICollection? User_CC { get; set; } public string GetFullName() { diff --git a/exercise.wwwapi/Models/UserCC.cs b/exercise.wwwapi/Models/UserCC.cs index 0c07317..9a45a76 100644 --- a/exercise.wwwapi/Models/UserCC.cs +++ b/exercise.wwwapi/Models/UserCC.cs @@ -1,11 +1,12 @@ using exercise.wwwapi.Models; +using exercise.wwwapi.Repository; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace exercise.wwwapi.Models -{ +namespace exercise.wwwapi.Models; + [Table("user_cc")] - public class UserCC + public class UserCC : IEntity { [Key] [Column("id")] @@ -17,7 +18,6 @@ public class UserCC [ForeignKey(nameof(User))] [Column("user_id")] - public int UserId { get; set; } public CohortCourse CohortCourse { get; set; } @@ -25,4 +25,4 @@ public class UserCC public User User { get; set; } } -} + diff --git a/exercise.wwwapi/Models/UserExercise.cs b/exercise.wwwapi/Models/UserExercise.cs index 9f5e686..0f2f74b 100644 --- a/exercise.wwwapi/Models/UserExercise.cs +++ b/exercise.wwwapi/Models/UserExercise.cs @@ -1,4 +1,5 @@ using exercise.wwwapi.Enums; +using exercise.wwwapi.Repository; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json.Serialization; @@ -6,7 +7,7 @@ namespace exercise.wwwapi.Models; [Table("User_Exercises")] -public class UserExercise +public class UserExercise : IEntity { [Key] [Column("id")] diff --git a/exercise.wwwapi/Program.cs b/exercise.wwwapi/Program.cs index 0eb0f5f..0a6ee92 100644 --- a/exercise.wwwapi/Program.cs +++ b/exercise.wwwapi/Program.cs @@ -40,6 +40,7 @@ builder.Services.AddScoped, Repository>(); builder.Services.AddScoped, Repository>(); builder.Services.AddScoped, Repository>(); +builder.Services.AddScoped, Repository>(); // Register general services builder.Services.AddScoped(); diff --git a/exercise.wwwapi/Repository/IRepository.cs b/exercise.wwwapi/Repository/IRepository.cs index d86019f..c2e5743 100644 --- a/exercise.wwwapi/Repository/IRepository.cs +++ b/exercise.wwwapi/Repository/IRepository.cs @@ -2,8 +2,10 @@ namespace exercise.wwwapi.Repository; -public interface IRepository where T : class +public interface IRepository { + Task> GetWithIncludes(Func, IQueryable> includeQuery); + Task GetByIdWithIncludes(Func, IQueryable> includeQuery, int id); IEnumerable GetAll(params Expression>[] includeExpressions); Task> GetAllAsync(params Expression>[] includeExpressions); T? GetById(object id, params Expression>[] includeExpressions); diff --git a/exercise.wwwapi/Repository/Repository.cs b/exercise.wwwapi/Repository/Repository.cs index 85fe6bb..95b6fbc 100644 --- a/exercise.wwwapi/Repository/Repository.cs +++ b/exercise.wwwapi/Repository/Repository.cs @@ -4,7 +4,7 @@ namespace exercise.wwwapi.Repository; -public class Repository : IRepository where T : class +public class Repository : IRepository where T : class, IEntity { private readonly DataContext _db; private readonly DbSet _table; @@ -113,4 +113,17 @@ public async Task SaveAsync() { await _db.SaveChangesAsync(); } + + public async Task> GetWithIncludes(Func, IQueryable> includeQuery) + { + IQueryable query = includeQuery(_table); + return await query.ToListAsync(); + } + + public async Task GetByIdWithIncludes(Func, IQueryable> includeQuery, int id) + { + IQueryable query = includeQuery(_table); + var res = await query.Where(a => a.Id == id).FirstOrDefaultAsync(); + return res; + } } \ No newline at end of file diff --git a/exercise.wwwapi/Validators/UserValidators/UserUpdateValidator.cs b/exercise.wwwapi/Validators/UserValidators/UserUpdateValidator.cs index c0d9027..173346e 100644 --- a/exercise.wwwapi/Validators/UserValidators/UserUpdateValidator.cs +++ b/exercise.wwwapi/Validators/UserValidators/UserUpdateValidator.cs @@ -23,7 +23,7 @@ public UserUpdateValidator() RuleFor(x => x.Password) .Matches(@"[^a-zA-Z0-9\s]+").WithMessage("Password must contain at least one special character"); - RuleFor(x => x.Phone) + RuleFor(x => x.Mobile) .Matches(@"^+?\d{7,15}$").WithMessage("Phone must be a valid phone number."); } } \ No newline at end of file diff --git a/exercise.wwwapi/exercise.wwwapi.csproj b/exercise.wwwapi/exercise.wwwapi.csproj index 08bcefd..276f572 100644 --- a/exercise.wwwapi/exercise.wwwapi.csproj +++ b/exercise.wwwapi/exercise.wwwapi.csproj @@ -10,23 +10,23 @@ - - - - - + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + +