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)); }
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); }
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)); }