public async Task GetAllUpuDegreesAsync_Valid() { //Arrange _repoWrapper.Setup(r => r.UpuDegree.GetAllAsync(It.IsAny <Expression <Func <UpuDegree, bool> > >(), It.IsAny <Func <IQueryable <UpuDegree>, IIncludableQueryable <UpuDegree, object> > >())).ReturnsAsync(new List <UpuDegree>().AsQueryable()); _mapper.Setup(x => x.Map <UpuDegree, UpuDegreeDTO>(It.IsAny <UpuDegree>())).Returns(new UpuDegreeDTO()); // Act var result = await _userPersonalDataService.GetAllUpuDegreesAsync(); // Assert Assert.NotNull(result); Assert.IsInstanceOf <IEnumerable <UpuDegreeDTO> >(result); }
public async Task <IActionResult> Edit(string userId) { if (userId == null) { _loggerService.LogError("User id is null"); return(NotFound()); } var user = await _userService.GetUserAsync(userId); var currentUserId = _userManager.GetUserId(User); var currentUser = await _userService.GetUserAsync(currentUserId); if (!(userId == currentUserId || await _userManagerService.IsInRoleAsync(currentUser, Roles.Admin))) { _loggerService.LogError($"User (id: {currentUserId}) hasn't access to edit profile (id: {userId})"); return(StatusCode(StatusCodes.Status403Forbidden)); } if (user != null) { var genders = _mapper.Map <IEnumerable <GenderDTO>, IEnumerable <GenderViewModel> >(await _userPersonalDataService.GetAllGendersAsync()); var placeOfStudyUnique = _mapper.Map <IEnumerable <EducationDTO>, IEnumerable <EducationViewModel> >(await _userPersonalDataService.GetAllEducationsGroupByPlaceAsync()); var specialityUnique = _mapper.Map <IEnumerable <EducationDTO>, IEnumerable <EducationViewModel> >(await _userPersonalDataService.GetAllEducationsGroupBySpecialityAsync()); var placeOfWorkUnique = _mapper.Map <IEnumerable <WorkDTO>, IEnumerable <WorkViewModel> >(await _userPersonalDataService.GetAllWorkGroupByPlaceAsync()); var positionUnique = _mapper.Map <IEnumerable <WorkDTO>, IEnumerable <WorkViewModel> >(await _userPersonalDataService.GetAllWorkGroupByPositionAsync()); var upuDegrees = _mapper.Map <IEnumerable <UpuDegreeDTO>, IEnumerable <UpuDegreeViewModel> >(await _userPersonalDataService.GetAllUpuDegreesAsync()); var educView = new UserEducationViewModel { PlaceOfStudyID = user.UserProfile.EducationId, SpecialityID = user.UserProfile.EducationId, PlaceOfStudyList = placeOfStudyUnique, SpecialityList = specialityUnique }; var workView = new UserWorkViewModel { PlaceOfWorkID = user.UserProfile.WorkId, PositionID = user.UserProfile.WorkId, PlaceOfWorkList = placeOfWorkUnique, PositionList = positionUnique }; var model = new EditUserViewModel() { User = _mapper.Map <UserDTO, UserViewModel>(user), Nationalities = _mapper.Map <IEnumerable <NationalityDTO>, IEnumerable <NationalityViewModel> >(await _userPersonalDataService.GetAllNationalityAsync()), Religions = _mapper.Map <IEnumerable <ReligionDTO>, IEnumerable <ReligionViewModel> >(await _userPersonalDataService.GetAllReligionsAsync()), EducationView = educView, WorkView = workView, Degrees = _mapper.Map <IEnumerable <DegreeDTO>, IEnumerable <DegreeViewModel> >(await _userPersonalDataService.GetAllDegreesAsync()), Genders = genders, UpuDegrees = upuDegrees, }; return(Ok(model)); } _loggerService.LogError($"User not found. UserId:{userId}"); return(NotFound()); }