public async Task ShouldDeleteShooterAssociationInfoBeOkHavingProvidedData() { var existing = Scenario.ShooterAssociationInfos.FirstOrDefault(); //Conteggio gli elementi prima della creazione var countBefore = Scenario.ShooterAssociationInfos.Count; //Composizione della request var request = new ShooterAssociationInfoRequest { ShooterAssociationInfoId = existing.Id }; //Invoke del metodo var response = await Controller.DeleteShooterAssociationInfo(request); //Conteggio gli elementi dopo la creazione var countAfter = Scenario.ShooterAssociationInfos.Count; //Parsing della risposta e assert var parsed = ParseExpectedOk <OkResponse>(response); Assert.IsTrue(parsed != null // the old one should be closed with end date && countAfter == countBefore - 1 ); }
public async Task <IActionResult> DeleteShooterAssociationInfo(ShooterAssociationInfoRequest request) { //Recupero l'elemento dal business layer var entity = BasicLayer.GetShooterAssociationInfo(request.ShooterAssociationInfoId); //Se l'utente non hai i permessi non posso rimuovere entità con userId nullo if (entity == null) { return(NotFound()); } //Invocazione del service layer var validations = await BasicLayer.DeleteShooterAssociationInfo(entity, PlatformUtils.GetIdentityUserId(User)); if (validations.Count > 0) { return(BadRequest(validations)); } //Return contract return(Ok(new OkResponse { Status = true })); }