public UIElement GetAddElement() { UIElement element = null; DataServiceMessage <IEnumerable <string> > sportServiceMessage; DataServiceMessage <IEnumerable <TournamentDisplayDTO> > tournamentServiceMessage; DataServiceMessage <IEnumerable <ParticipantTournamentDTO> > participantServiceMessage; using (ITournamentService service = factory.CreateTournamentService()) { tournamentServiceMessage = service.GetAll(); RaiseReceivedMessageEvent(tournamentServiceMessage.IsSuccessful, tournamentServiceMessage.Message); } using (ISportService service = factory.CreateSportService()) { sportServiceMessage = service.GetAll(); RaiseReceivedMessageEvent(sportServiceMessage.IsSuccessful, sportServiceMessage.Message); } using (IParticipantService service = factory.CreateParticipantService()) { participantServiceMessage = service.GetAllWithTournaments(); RaiseReceivedMessageEvent(sportServiceMessage.IsSuccessful, sportServiceMessage.Message); } if (tournamentServiceMessage.IsSuccessful && sportServiceMessage.IsSuccessful && participantServiceMessage.IsSuccessful) { IEnumerable <string> sports = sportServiceMessage.Data; IEnumerable <TournamentDisplayDTO> tournamentDisplayDTOs = tournamentServiceMessage.Data; IEnumerable <ParticipantTournamentDTO> participantTournamentDTOs = participantServiceMessage.Data; IEnumerable <TournamentBaseModel> tournamentBaseModels = tournamentDisplayDTOs .Select(t => Mapper.Map <TournamentDisplayDTO, TournamentBaseModel>(t)) .ToList(); IEnumerable <ParticipantTournamentModel> participantTournamentModels = participantTournamentDTOs .Select(p => Mapper.Map <ParticipantTournamentDTO, ParticipantTournamentModel>(p)) .ToList(); element = Add(sports, tournamentBaseModels, participantTournamentModels); } else { List <ServiceMessage> messages = new List <ServiceMessage>() { sportServiceMessage, tournamentServiceMessage, participantServiceMessage }; ErrorViewModel viewModel = new ErrorViewModel(messages); ErrorControl control = new ErrorControl(viewModel); element = control; } return(element); }