Пример #1
0
        public static async Task <List <LiveMatchViewModel> > GetGames(string teamId)
        {
            List <LiveMatchViewModel> vtr = new List <LiveMatchViewModel>();

            try
            {
                var result = await GrpcClients.GrpcClientFootballMatch(URLS.Server).RequestMatchesForTeamAsync(new Grpc.Protos.Football.ProtoMessageRequestMatches()
                {
                    TeamId = teamId
                });

                vtr = result.ListOfLiveMatchViewModel?.Select(lm => ProtoMessageLiveMatchViewModel_LiveMatchViewModel_Adapter.Map(lm))?.ToList() ?? new List <LiveMatchViewModel>();
            }
            catch (Exception)
            {
                //TODO: Notifications or something
            }
            return(vtr);
        }
Пример #2
0
        public static async Task<List<LiveMatchViewModel>> GetAllLiveMatches(Func<List<string>, Task> displayNotice)
        {
            if (displayNotice == null)
                displayNotice = (n) => Task.CompletedTask; 

            List<LiveMatchViewModel> vtr = new List<LiveMatchViewModel>();
            try
            {
                if (await HasInternet(displayNotice))
                {
                    ProtoMessageRequestMatches protoMessageRequestMatches = new ProtoMessageRequestMatches() { TeamId = Variables.ArsenalTeamId };
                    var resultProto = await GrpcClients.GrpcClientFootballMatch(SanitizeMobileUrlForEmulator(URLS.Server)).RequestMatchesForTeamAsync(protoMessageRequestMatches);

                    resultProto.ListOfLiveMatchViewModel.ForEach(lm => vtr.Add(ProtoMessageLiveMatchViewModel_LiveMatchViewModel_Adapter.Map(lm)));
                }
            }
            catch (Exception)
            {
                await displayNotice(new List<string>() { "Unknown error occured" });
            }
            return vtr ?? new List<LiveMatchViewModel>();
        }