public ActionResult <InschrijvingVoorRaadpleegDto> ToevoegenInschrijving([FromBody] InschrijvingVoorAanmaakDto inschrijving) { var inschrijvingEntity = _mapper.Map <Entities.Inschrijving>(inschrijving); inschrijvingEntity.DatumInschrijving = DateTime.UtcNow.AddHours(2); // === START Controle voor manipulatie === // // === EINDE Controle voor manipulatie === // if (!_betaalmethodeRepository.BestaatBetaalmethode(inschrijvingEntity.BetaalmethodeId.Value)) { return(NotFound($"Betaalmethode '{inschrijvingEntity.BetaalmethodeId.Value}' niet gevonden.")); } if (!_inschrijvingsstatusRepository.BestaatInschrijvingsstatus(inschrijvingEntity.InschrijvingsstatusId.Value)) { return(NotFound($"Inschrijvingsstatus '{inschrijvingEntity.InschrijvingsstatusId.Value}' niet gevonden.")); } if (!_evenementRepository.BestaatEvenement(inschrijvingEntity.EvenementId.Value)) { return(NotFound($"Evenement '{inschrijvingEntity.EvenementId.Value}' niet gevonden.")); } if (inschrijvingEntity.LidId.HasValue) { if (!_lidRepository.BestaatLid(inschrijvingEntity.LidId.Value)) { return(NotFound($"Lid '{inschrijvingEntity.LidId.Value}' niet gevonden.")); } } if (inschrijvingEntity.InschrijvingsstatusId.Value == _inschrijvingsstatusRepository.GetInschrijvingsstatus_Gepland().Id) { if (string.IsNullOrWhiteSpace(inschrijvingEntity.Standnummer)) { return(Conflict($"Bij het plannen van een inschrijving moet een standnummer worden opgegeven.")); } } if (inschrijvingEntity.InschrijvingsstatusId.Value == _inschrijvingsstatusRepository.GetInschrijvingsstatus_Afgekeurd().Id) { if (string.IsNullOrWhiteSpace(inschrijvingEntity.RedenAfkeuring)) { return(Conflict($"Bij het afkeuren van een inschrijving moet een reden tot afkeuring worden opgegeven.")); } } if (inschrijvingEntity.InschrijvingsstatusId.Value == _inschrijvingsstatusRepository.GetInschrijvingsstatus_Goedgekeurd().Id | inschrijvingEntity.InschrijvingsstatusId.Value == _inschrijvingsstatusRepository.GetInschrijvingsstatus_Gepland().Id) { if (inschrijvingEntity.BetaalmethodeId.Value == _betaalmethodeRepository.GetBetaalmethode_Overschrijving().Id) { if (string.IsNullOrWhiteSpace(inschrijvingEntity.GestructureerdeMededeling)) { inschrijvingEntity.GestructureerdeMededeling = GestructureerdeMededeling.GetNieuweGestructureerdeMededeling(_inschrijvingRepository); } } if (string.IsNullOrWhiteSpace(inschrijvingEntity.QRCode)) { inschrijvingEntity.QRCode = QRCode.GetNieuweQRCode(); } } // === EINDE Controle voor manipulatie === // // === START null waarden wegwerken === // if (!inschrijvingEntity.AantalWagens.HasValue) { inschrijvingEntity.AantalWagens = 0; } if (!inschrijvingEntity.AantalAanhangwagens.HasValue) { inschrijvingEntity.AantalAanhangwagens = 0; } if (!inschrijvingEntity.AantalMobilhomes.HasValue) { inschrijvingEntity.AantalMobilhomes = 0; } // === EINDE null waarden wegwerken === // _inschrijvingRepository.ToevoegenInschrijving(inschrijvingEntity); _inschrijvingRepository.Opslaan(); if (inschrijvingEntity.InschrijvingsstatusId.Value == _inschrijvingsstatusRepository.GetInschrijvingsstatus_Aangevraagd().Id) { _mailing.VerstuurMail_NieuweAanvraag(inschrijvingEntity); } var inschrijvingTeRetourneren = _mapper.Map <InschrijvingVoorRaadpleegDto>(inschrijvingEntity); return(CreatedAtRoute("GetInschrijving", new { inschrijvingsId = inschrijvingTeRetourneren.Id }, inschrijvingTeRetourneren)); }