Skip to content

Commit

Permalink
refine and update user entity
Browse files Browse the repository at this point in the history
  • Loading branch information
lehquy13 committed Mar 22, 2023
1 parent 4c93f97 commit e00f7ee
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 194 deletions.
6 changes: 3 additions & 3 deletions CED.Contracts/Users/AdminDto.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using CED.Domain.Shared.ClassInformationConsts;
using Abp.Application.Services.Dto;
using CED.Domain.Shared.ClassInformationConsts;

namespace CED.Contracts.Users;
public class AdminDto
public class AdminDto : FullAuditedEntityDto<Guid>
{
//Admin information
public Guid Id { get; set; } = Guid.NewGuid();
public string FirstName { get; set; } = string.Empty;
public string LastName { get; set; } = string.Empty;
public Gender Gender { get; set; } = Gender.Male;
Expand Down
6 changes: 3 additions & 3 deletions CED.Contracts/Users/StudentDto .cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using CED.Domain.Shared.ClassInformationConsts;
using Abp.Application.Services.Dto;
using CED.Domain.Shared.ClassInformationConsts;

namespace CED.Contracts.Users;
public class StudentDto
public class StudentDto : FullAuditedEntityDto<Guid>
{
//Admin information
public Guid Id { get; set; } = Guid.NewGuid();
public string FirstName { get; set; } = string.Empty;
public string LastName { get; set; } = string.Empty;
public Gender Gender { get; set; } = Gender.Male;
Expand Down
6 changes: 3 additions & 3 deletions CED.Contracts/Users/TutorDto.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using CED.Domain.Shared.ClassInformationConsts;
using Abp.Application.Services.Dto;
using CED.Domain.Shared.ClassInformationConsts;

namespace CED.Contracts.Users;
public class TutorDto
public class TutorDto : FullAuditedEntityDto<Guid>
{
//Admin information
public Guid Id { get; set; } = Guid.NewGuid();
public string FirstName { get; set; } = string.Empty;
public string LastName { get; set; } = string.Empty;
public Gender Gender { get; set; } = Gender.Male;
Expand Down
6 changes: 3 additions & 3 deletions CED.Contracts/Users/UserDto.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using CED.Domain.Shared.ClassInformationConsts;
using Abp.Application.Services.Dto;
using CED.Domain.Shared.ClassInformationConsts;

namespace CED.Contracts.Users;
public class UserDto
public class UserDto : FullAuditedEntityDto<Guid>
{
//User information
public Guid Id { get; set; } = Guid.NewGuid();
public string FirstName { get; set; } = string.Empty;
public string LastName { get; set; } = string.Empty;
public Gender Gender { get; set; } = Gender.Male;
Expand Down
3 changes: 2 additions & 1 deletion CED.Domain.Shared/ClassInformationConsts/UserRole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ public enum UserRole
Undefined,
Admin,
Tutor,
Student
Student,
All
}
58 changes: 51 additions & 7 deletions CED.Domain/Users/User.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using CED.Domain.Shared.ClassInformationConsts;
using Abp.Domain.Entities.Auditing;
using CED.Domain.Shared.ClassInformationConsts;

namespace CED.Domain.Users;
public class User
public class User : FullAuditedAggregateRoot<Guid>
{
//User information
public Guid Id { get; set; } = Guid.NewGuid();
public string FirstName { get; set; } = string.Empty;
public string LastName { get; set; } = string.Empty;
public Gender Gender { get; set; } = Gender.Male;
Expand All @@ -25,12 +25,56 @@ public class User
public string University { get; set;} = string.Empty;
public bool isVerified { get; set; } = false;

public void TutorRegistration(User tutorDto)
/// <summary>
/// Update current user to be tutor
/// </summary>
/// <param name="tutor"></param>

public void RegisterToBeTutor(User tutor)
{
Role = tutor.Role;
AcademicLevel = tutor.AcademicLevel;
University = tutor.University;
}

/// <summary>
/// Update tutor's information and change the state into being verified
/// </summary>
/// <param name="tutor"></param>

public void UpdateTutorInformation(User tutor)
{
Role = tutorDto.Role;
AcademicLevel = tutorDto.AcademicLevel;
University = tutorDto.University;
FirstName = tutor.FirstName;
LastName = tutor.LastName;
Gender = tutor.Gender;
BirthYear = tutor.BirthYear;
Address = tutor.Address;
Description = tutor.Description;

PhoneNumber = tutor.PhoneNumber;

AcademicLevel = tutor.AcademicLevel;
University = tutor.University;

//wait for being verified
isVerified = false;

}

/// <summary>
/// Update standard user's information
/// </summary>
/// <param name="user"></param>
public void UpdateUserInformation(User user)
{
FirstName = user.FirstName;
LastName = user.LastName;
Gender = user.Gender;
BirthYear = user.BirthYear;
Address = user.Address;
Description = user.Description;

PhoneNumber = user.PhoneNumber;
}
}

This file was deleted.

113 changes: 0 additions & 113 deletions CED.WebAPI/Controllers/Persistence/Repository/Repository.cs

This file was deleted.

24 changes: 0 additions & 24 deletions CED.WebAPI/Controllers/Persistence/Repository/SubjectRepository.cs

This file was deleted.

25 changes: 0 additions & 25 deletions CED.WebAPI/Controllers/Persistence/Repository/UserRepository.cs

This file was deleted.

0 comments on commit e00f7ee

Please sign in to comment.