Exemplo n.º 1
0
        /// <summary>
        /// Lấy ra danh sách thông báo
        /// </summary>
        /// <param name="UserId"></param>
        /// <param name="top"></param>
        /// <param name="notiSpecType"></param>
        /// <returns></returns>
        public async Task <LstFCMMessageUser> GetListMsgByUser(int?top, int notiSpecType)
        {
            LstFCMMessageUser output = new LstFCMMessageUser();

            try
            {
                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/GetListMsgByUser";
                    string paramRequest = $"?UserID={jwt.UserId}&Top={top}&NotiSpecType={notiSpecType}";
                    var    response     = await _client.GetAsync(apiUrl + paramRequest);

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

                        output = JsonConvert.DeserializeObject <LstFCMMessageUser>(responseStream);
                    }
                }
            }
            catch (Exception e)
            {
            }

            return(output);
        }
Exemplo n.º 2
0
        public async Task <LstFCMMessageUser> GetListMsgByUser(string UserID, int Top, int?NotiSpecType = 0)
        {
            var output = new LstFCMMessageUser();

            try
            {
                var lstFCMMessage = await _repoWrapper.FCMMessage.GetListMsgByUser(UserID, Top, NotiSpecType);

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

                List <LstFCMMessage> lstItem = new List <LstFCMMessage>();
                if (lstFCMMessage.Count() > 0)
                {
                    foreach (var p in lstFCMMessage)
                    {
                        var item = new LstFCMMessage();
                        item.FCMMessageId = p.FCMMessage_ID;
                        item.Title        = p.Title ?? "";
                        item.Body         = HttpUtility.HtmlDecode(p.Body) ?? "";
                        item.notifyType   = p.NotificationType ?? 0;
                        item.formId       = p.Form_ID ?? "";
                        item.id           = p.ParameterId ?? 0;
                        item.categoryId   = p.CategoryId ?? 0;
                        item.fullUrl      = p.FullUrl ?? "";
                        item.fullUrlImage = p.FullUrlImage ?? "";
                        item.typeId       = p.ProductTypeId ?? 0;
                        item.notiSpecType = p.NotiSpecType ?? 0;
                        item.isPinTop     = p.IsPinTop ?? 0;
                        item.formAppName  = p.FormNameApp ?? "";
                        item.CreateDate   = p.CreateDate;
                        item.HasRead      = p.HasRead ?? 0;
                        lstItem.Add(item);
                    }
                }
                output.LstFCMMessage = lstItem;
                output.NumberUnread  = numberUnread;
            }
            catch (Exception ex)
            {
                _logger.LogError($"GetListMsgByUser: " + ex.ToString());
            }
            return(output);
        }