public async void UpdateFestivalShouldUpdateFestival(int festivalId) { Festival festival = await _dbMock.Object.Festivals.FirstAsync(f => f.Id == festivalId); festival.FestivalName = "New Name"; await _festivalService.UpdateFestival(festival); Assert.Equal("New Name", _festivalService.GetFestival(festivalId).FestivalName); }
public void Should_Throw_Exception_When_No_Element_To_Update() { //Arrange const int id = 100; var festival = new Festival { Name = "Test", Description = "TestDescription", Id = id }; //Act + assert Assert.ThrowsAsync <ElementNotFoundException>(async() => await _service.UpdateFestival(festival)); }
public async Task <ActionResult> UpdateFestival(int id, [FromBody] FestivalUpdateRequestBody updateRequestBody) { var validationResult = await _updateValidator.ValidateAsync(updateRequestBody); if (!validationResult.IsValid) { return(BadRequest(validationResult.Errors)); } var festival = _mapper.Map <Festival>(updateRequestBody); if (id != festival.Id) { return(BadRequest()); } await _service.UpdateFestival(festival); return(Ok(festival)); }
public async void UpdateFestival() { try { await _festivalService.UpdateFestival(Festival); _festivalService.Sync(); _navigationService.NavigateTo("FestivalInfo", Festival.Id); } catch (InvalidDataException) { OpenValidationPopup($"Ingevoerde data incorrect."); } catch (InvalidAddressException) { OpenValidationPopup("Er is een ongeldig adres ingevoerd, controleer of je minimaal een straat, postcode en plaats hebt."); } catch (EndDateEarlierThanStartDateException) { OpenValidationPopup("De einddatum moet later zijn dan de startdatum"); } }