/// <summary> /// Verwijdert een gegeven communicatievorm. /// </summary> /// <param name="model">Gegevens die moeten toelaten de communicatievorm te verwijderen.</param> public void CommunicatieVormVerwijderen(CommunicatieVormModel model) { var gevonden = (from cv in _communicatieVormenRepo.Select() where cv.GelieerdePersoon.Persoon.AdNummer == model.AdNummer && cv.CommunicatieType.ID == model.CommunicatieTypeId && cv.Nummer == model.Nummer select cv); if (!gevonden.Any()) { throw new FoutNummerException(FoutNummer.CommunicatieVormNietGevonden, String.Empty); } _communicatieVormenRepo.Delete(gevonden.ToList()); _communicatieVormenRepo.SaveChanges(); Console.WriteLine("Communicatie {0} (type {1}, AD-nr {2}) verwijderd", model.Nummer, model.CommunicatieTypeId, model.AdNummer); }
public CommunicatieVormModule(IGapUpdater gapUpdater) { _gapUpdater = gapUpdater; // curl -X DELETE -d AdNummer=xx -d CommunicatieTypeId=3 -d [email protected] http://localhost:50673/communicatievorm Delete["/communicatievorm"] = _ => { CommunicatieVormModel model = this.Bind(); try { _gapUpdater.CommunicatieVormVerwijderen(model); } catch (FoutNummerException e) { if (e.FoutNummer == FoutNummer.CommunicatieVormNietGevonden) { return(HttpStatusCode.NotFound); } throw; } return(HttpStatusCode.OK); }; }