コード例 #1
0
        public async Task <ActionResult <UserForProfileViewDto> > GetUserData(int id)
        {
            var user = await _profileRepository.GetUser(id);

            var userForView   = _mapper.Map <UserForProfileViewDto>(user);
            var institutionId = user.InstitutionId ?? default(int);

            if (user.InstitutionId > 0)
            {
                userForView.InstitutionName =
                    await _institutionRepository.FindName(userForView.Category, institutionId);
            }
            return(Ok(userForView));
        }
コード例 #2
0
        public async Task <AmbassadorProfileDto> GetAmbassador(int id)
        {
            var user = await _context.Users.Include(user => user.Ambassador).FirstOrDefaultAsync(user => user.Id == id);

            var ambassadorForView = _mapper.Map <AmbassadorProfileDto>(user);
            var institutionId     = user.InstitutionId ?? default(int);

            ambassadorForView.InstitutionName = await _institution.FindName(user.Category, institutionId);

            ambassadorForView.AmbassadorId   = user.Ambassador.Id;
            ambassadorForView.FreeMembership = user.Ambassador.FreeMembership;
            ambassadorForView.PaidMembership = user.Ambassador.PaidMembership;
            return(ambassadorForView);
        }
コード例 #3
0
        public async Task <ActionResult <UserForProfileViewDto> > View()
        {
            var id   = int.Parse(User.Claims.First(i => i.Type == "user_id").Value);
            var user = await _repo.GetUser(id);

            var userForView   = _mapper.Map <UserForProfileViewDto>(user);
            var institutionId = user.InstitutionId ?? default(int);

            if (user.InstitutionId > 0)
            {
                userForView.InstitutionName = await _institution.FindName(userForView.Category, institutionId);
            }
            return(Ok(userForView));
        }