public Task <IActionResult> FetchShooterAssociationInfo(ShooterRequest request) { //Recupero l'elemento dal business layer var entity = BasicLayer.GetShooter(request.ShooterId); //modifica solo se admin o se utente richiedente è lo stesso che ha creato if (entity == null) { return(Task.FromResult <IActionResult>(NotFound())); } ; //Invocazione del service layer var shooterAssociations = BasicLayer.FetchShooterAssociationInfoByShooterId(entity.Id); var associationIds = shooterAssociations.Select(x => x.AssociationId).ToList(); var associations = BasicLayer.FetchAssociationsByIds(associationIds); //Return contract return(Reply( shooterAssociations.As(x => ContractUtils.GenerateContract(x, associations.FirstOrDefault(a => a.Id == x.AssociationId))) .OrderBy(x => x.Association.Name).ToList() )); }