public async Task <JsonResult> GetMessage(int msgId)
        {
            var result = await _messageRepository.GetDetailMessage(msgId, SiteUser.UserId);

            var message          = result.Keys.FirstOrDefault();
            var previousReadMode = message?.MessageRead ?? true;

            //update status for message, mark messgage to read
            var isSuccessSetRead = true;

            if (!previousReadMode) // if read mode = false (unread = true), set read mode = true
            {
                isSuccessSetRead = await _messageRepository.SetMessageReadmode(SiteUser.UserId, new[] { msgId }, true);
            }

            if (result.Keys.Count <= 0)
            {
                return(Json(new { }));
            }

            var messageStatus = await _messageRepository.GetDetailMessageStatus(SiteUser.UserId, msgId);

            var status = messageStatus?.Status ?? 0;

            //var sortedResult = result.Keys.OrderBy(x=>x.del)

            var messages = result.Select(msg => new
            {
                id                 = msg.Key.MessageId,
                header             = msg.Key.HeadLine,
                content            = msg.Key.MailMessage,
                categoryId         = msg.Key.MessageArea,
                categoryName       = msg.Key.AreaDescription,
                isUnRead           = !isSuccessSetRead, //
                isStarred          = status == (int)MessageStatus.Starred,
                isTrash            = status == (int)MessageStatus.InTrash,
                isDelete           = status == (int)MessageStatus.Deleted,
                receivedDate       = $"{msg.Key.SendDate:yyyy-MM-dd}",
                customerAddress    = msg.Key.CustomerAddress,
                customerName       = msg.Key.CustomerName,
                customerZipAndCity = msg.Key.CustomerZipAndCity,
                messageTable       = IsShowTableOnMessage(msg.Key.MessageType)
                    ? GetDeliveryTableInfor(msg.Key.MessageType,
                                            msg.Value.Where(item => !string.IsNullOrEmpty(item.OrderNo)).OrderByDescending(x => x.PlannedDeliveryDate))
                    : null,
                messageType = message?.MessageType ?? 0,
                //deliveriesView= this.RenderPartialViewToString("~/Views/DeliveryMessagesPage/DeliveriesTables.cshtml", null)
                deliveriesView = GetPlannedDeliveriesView(msg.Key.MessageId, msg.Key.CustomerName)
            });

            return(Json(new
            {
                message = messages.FirstOrDefault(),
                isNeedUpdate = previousReadMode == false && isSuccessSetRead
            }));
        }