public Task <IActionResult> FetchAvailableAssociationsForShooter(ShooterRequest request) { var associationIds = BasicLayer.FetchAllShooterAssociationInfos(request.ShooterId) .Select(x => x.AssociationId) .ToList(); //Recupero la lista dal layer var entities = BasicLayer.FetchAssociationsByIds(associationIds); //Ritorno i contratti return(Reply(entities.As(x => ContractUtils.GenerateContract(x)))); }
public Task <IActionResult> FetchAllMatches() { //Recupero la lista dal layer var entities = BasicLayer.FetchAllMatches(); var associationIds = entities.Select(x => x.AssociationId).ToList(); var placeIds = entities.Select(x => x.PlaceId).ToList(); var associations = BasicLayer.FetchAssociationsByIds(associationIds); var places = BasicLayer.FetchPlacesByIds(placeIds); //Ritorno i contratti return(Reply(entities.As(x => ContractUtils.GenerateContract(x, associations.FirstOrDefault(p => p.Id == x.AssociationId), places.FirstOrDefault(p => p.Id == x.PlaceId))))); }
public Task <IActionResult> FetchAllStages(MatchRequest request) { //Recupero la lista dal layer var entities = BasicLayer.FetchAllStages(request.MatchId); //seleziono gli id dei posti var matchIds = entities.Select(x => x.MatchId).ToList(); //recupero gli utenti var matches = this.BasicLayer.FetchMatchesByIds(matchIds); var associationIds = matches.Select(x => x.AssociationId).ToList(); var associations = BasicLayer.FetchAssociationsByIds(associationIds); //Ritorno i contratti return(Reply(entities.As(x => { var match = matches.FirstOrDefault(p => p.Id == x.MatchId); return ContractUtils.GenerateContract(x, match, associations.FirstOrDefault(p => p.Id == match.AssociationId)); }))); }
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() )); }