Example #1
0
        public async Task <FCMHasReadDTO> FCMHasRead(string UserId, int HasRead, int?FCMMessageID = 0, int?NotiSpecType = 0)
        {
            var output = new FCMHasReadDTO();

            try
            {
                var result = await _repoWrapper.FCMMessage.UpdateHasRead(UserId, HasRead, FCMMessageID, NotiSpecType);

                var numberUnread = await _repoWrapper.FCMMessage.GetNumberFCMUnread(UserId);

                output.NumberUnread = numberUnread;
                if (result == 0)
                {
                    output.ErrorCode = "01";
                    output.Message   = "Có lỗi trong quá trình update";
                }
                else
                {
                    output.ErrorCode = "00";
                    output.Message   = "Cập nhật thành công";
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"FCMHasRead: " + ex.ToString());
                output.ErrorCode = "01";
                output.Message   = "Có lỗi trong quá trình update";
            }
            return(output);
        }
Example #2
0
        public async Task <FCMHasReadDTO> CountFCMHasRead()
        {
            FCMHasReadDTO output = new FCMHasReadDTO();
            var           jwt    = JsonConvert.DeserializeObject <SumProfileResponseDTO>(_httpContextAccessor.HttpContext.Request.Cookies["JWT"]);

            if (jwt != null)
            {
                _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", jwt.JWT);
                string apiUrl       = $"/api/v1/FCMMessage/FCMHasRead";
                string paramRequest = $"?UserId={jwt.UserId}";
                var    response     = await _client.GetAsync(apiUrl + paramRequest);

                if (response.IsSuccessStatusCode)
                {
                    string responseStream = await response.Content.ReadAsStringAsync();

                    output = JsonConvert.DeserializeObject <FCMHasReadDTO>(responseStream);
                }
            }
            return(output);
        }