public async Task <IActionResult> GetAdmins(int cityId) { if (cityId != 0) { return(Ok(await _cityAdministrationService.GetAdministrationByIdAsync(cityId))); } _loggerService.LogError("City id is 0"); return(BadRequest()); }
public async Task GetByCityIdAsyncCorrect() { // Arrange _repositoryWrapper.Setup(r => r.CityAdministration.GetAllAsync(It.IsAny <Expression <Func <DatabaseEntities.CityAdministration, bool> > >(), It.IsAny <Func <IQueryable <DatabaseEntities.CityAdministration>, IIncludableQueryable <DatabaseEntities.CityAdministration, object> > >())) .ReturnsAsync(new List <DatabaseEntities.CityAdministration> { new DatabaseEntities.CityAdministration() }); // Act await _cityAdministrationService.GetAdministrationByIdAsync(It.IsAny <int>()); // Assert _mapper.Verify(m => m.Map <IEnumerable <DatabaseEntities.CityAdministration>, IEnumerable <CityAdministrationDTO> >(It.IsAny <IEnumerable <DatabaseEntities.CityAdministration> >())); }
public async Task <IActionResult> GetAdmins(int cityId) { var res = _mapper.Map <IEnumerable <CityAdministrationDTO>, IEnumerable <CityAdministrationViewModel> >(await _cityAdministrationService.GetAdministrationByIdAsync(cityId)); return(PartialView(res)); }