Open Closed

Modify ProfileAppService #8724


0
ArturCorreia created

Hi,

Can you point me in the right direction on how I could connect a new table to an existing zero table in the user profile?

I think i need to modify ProfileAppService.cs and join the zero User table with my UserDetails table using LinQ.

But I need to modify the output DTO of the GetCurrentUserProfileForEdit method and return necessary information to profile edit modal. Then, I need to modify input DTO class of UpdateCurrentUserProfile method and update both User entity and my UserDetails entity in this method.

I’ve tried to figure it out but don’t think I’m on the right track can you point me exactly how I can achieve this within the 2 methods ?

I have also used my classes as a properties in your zero classes, dont know if that was the right thing to do and/or if joining the tables/classes based on ID's.

Could you show how & where I can achieve this?

Thanks


4 Answer(s)
  • 0
    ismcagdas created

    Hi @ArturCorreia

    Could you share your related entity for new table ? I can write a sample query and share it with you.

    Thanks,

  • 0
    ArturCorreia created

    Hi ismcagdas sure here you go, thank you.

    [Table("UserDetails")]
    public class UserDetail : FullAuditedEntity
    {
        public const int MaxJobTitleLength = 50;
        public const int MaxPrefersToBeCalledByNameLength = 50;
        public const int MaxTitleLength = 50;
        public const int MaxEmployeeNumberLength = 50;
        public const int MaxDepartmentLength = 50;
        public const int MaxSiteLength = 50;
        public const int MaxPhoneNumberLength = 50;
        public const int MaxMobileNumberLength = 50;
        public const int MaxLinkedInProfileURLLength = 200;
        public const int MaxTwitterProfileURLLength = 50;
        public const int MaxHobbiesLength = 100;
        public const int MaxFavouriteSportsTeamLength = 100;
        public const int MaxFavouriteBandsOrMusicsLength = 100;
        public const int MaxFavouriteArtistsOrMoviesLength = 100;
        public const int MaxMoreAboutMeLength = 4000;
        public const int MaxExternalContactCompanyNameLength = 50;
        public const int MaxExternalContactWebsiteLength = 200;
    
        public int UserId { get; set; }
    
        [MaxLength(MaxJobTitleLength)] 
        public string JobTitle { get; set; }
    
        public int LineManagerId { get; set; }
    
        [MaxLength(MaxPrefersToBeCalledByNameLength)]
        public string PrefersToBeCalledByName { get; set; }
    
        [MaxLength(MaxTitleLength)]
        public string Title { get; set; } 
    
        [MaxLength(MaxEmployeeNumberLength)]
        public string EmployeeNumber { get; set; }
    
        public DateTime DateOfBirth { get; set; }
    
        [MaxLength(MaxDepartmentLength)]
        public string Department{ get; set; }
    
        public int CountryId { get; set; }
    
        [MaxLength(MaxSiteLength)]
        public string Site { get; set; }
    
        [MaxLength(MaxPhoneNumberLength)]
        public string PhoneNumber { get; set; }
    
        [MaxLength(MaxMobileNumberLength)]
        public string MobileNumber { get; set; }
    
        [MaxLength(MaxLinkedInProfileURLLength)]
        public string LinkedInProfileURL { get; set; }
    
        [MaxLength(MaxTwitterProfileURLLength)]
        public string TwitterProfileURL { get; set; }
    
        public DateTime JoinedTheCompanyOnDate { get; set; }
    
        public DateTime JoinedTheDepartmentOnDate { get; set; }
    
        [MaxLength(MaxHobbiesLength)]
        public string Hobbies { get; set; }
    
        [MaxLength(MaxFavouriteSportsTeamLength)]
        public string FavouriteSportsTeam { get; set; }
    
        [MaxLength(MaxFavouriteBandsOrMusicsLength)]
        public string FavouriteBandsOrMusics { get; set; }
    
        [MaxLength(MaxFavouriteArtistsOrMoviesLength)]
        public string FavouriteArtistsOrMovies { get; set; } 
    
        [MaxLength(MaxMoreAboutMeLength)]
        public string MoreAboutMe { get; set; }
    
        public bool ExternalContactFlag { get; set; }
    
        [MaxLength(MaxExternalContactCompanyNameLength)]
        public string ExternalContactCompanyName { get; set; }
    
        public int ExternalContactTypeID { get; set; }
    
        [MaxLength(MaxExternalContactWebsiteLength)]
        public string ExternalContactWebsite { get; set; } 
    }
    
  • 0
    ismcagdas created

    Hi,

    You can basically write something like this;

    var query = (from user in _userRepository.GetAll()
    join userDetail in _userDetailRepository.GetAll() on user.Id equals userDetail.UserId
    select new {
    	UserName = user.Username,
    	...
    	Title = userDetail.Title,
    	...
    });
    
  • 0
    ArturCorreia created

    Hi ismcagdas

    Now that i have then join in place and no errors showing, what i notice now is that when running the server side app and when i execute the https://localhost:44301/api/services/app/Profile/GetCurrentUserProfileForEdit and dont seem to get all the joined data back from my own table and i do have data in both tables.

    Is there something else i'm missing like another map?

    Thanks.