public async Task AddAdministratorAsync_ReturnsAdministrator() { //Arrange _repoWrapper .Setup(s => s.CityAdministration.CreateAsync(cityAdm)); _adminTypeService .Setup(a => a.GetAdminTypeByNameAsync(It.IsAny <string>())) .ReturnsAsync(new AdminTypeDTO()); //Act var result = await _cityParticipantsService.AddAdministratorAsync(cityAdmDTO); //Assert Assert.IsInstanceOf <CityAdministrationDTO>(result); }
public async Task <IActionResult> AddAdmin(CityAdministrationViewModel newAdmin) { var admin = _mapper.Map <CityAdministrationViewModel, CityAdministrationDTO>(newAdmin); await _cityParticipantsService.AddAdministratorAsync(admin); _logger.LogInformation($"User {{{admin.UserId}}} became Admin for city {{{admin.CityId}}}" + $" with role {{{admin.AdminType.AdminTypeName}}}."); return(Ok(admin)); }