コード例 #1
0
ファイル: ChatService.cs プロジェクト: BuiKimPhat/Talktif
        public async Task <List <Room_Infor> > FetchAllChatRoom(HttpRequest Request, HttpResponse Response)
        {
            var cookie = _userService.ReadUserCookie(Request);
            var result = await _chatRepo.FetchAllChatRoom(cookie.id, cookie.token);

            string a = result.Content.ReadAsStringAsync().Result;

            if (result.IsSuccessStatusCode)
            {
                return(JsonConvert.DeserializeObject <List <Room_Infor> >(a));
            }
            else
            {
                await _userService.RefreshToken(Response, cookie);

                cookie = _userService.ReadUserCookie(Request);
                result = await _chatRepo.FetchAllChatRoom(cookie.id, cookie.token);

                a = result.Content.ReadAsStringAsync().Result;

                return(JsonConvert.DeserializeObject <List <Room_Infor> >(a));
            }
        }