public Task <IActionResult> DeleteStageSO(ShooterSOStageRequest request) { //Recupero l'elemento dal business layer var entity = BasicLayer.GetShooterSOStage(request.ShooterSOStageId); //Se l'utente non hai i permessi non posso rimuovere entità con userId nullo if (entity == null) { return(Task.FromResult <IActionResult>(NotFound())); } //Invocazione del service layer var validations = BasicLayer.DeleteShooterSOStage(entity); if (validations.Count > 0) { return(BadRequestTask(validations)); } var shooterSOStagees = BasicLayer.FetchShooterSOStagesByStageId(entity.StageId); var shooterIds = shooterSOStagees.Select(x => x.ShooterId).ToList(); var shooters = BasicLayer.FetchShootersByIds(shooterIds); //Return contract return(Reply(shooterSOStagees.As(x => ContractUtils.GenerateContract(x, shooters.FirstOrDefault(s => s.Id == x.ShooterId))))); }