Ejemplo n.º 1
0
        public IActionResult GetMessageByNotificationMessageId(Guid notificationMessageGuid)
        {
            try
            {
                var notificationMessageById =
                    _notificationMessageService.GetByNotificationMessageId(notificationMessageGuid);

                if (notificationMessageById != null)
                {
                    //this block is required to get the actual User name of user who created the notifications
                    var notificationMessage =
                        Models.ObjectMapper <NotificationMessage, NotificationMessageViewModel> .Map(
                            notificationMessageById);

                    var user = _userService.GetUserByUserGuid(notificationMessage.CreatedBy);

                    notificationMessage.CreatedByName =
                        Infrastructure.Helpers.FormatHelper.FormatFullName(user.Firstname, string.Empty, user.Lastname);
                    notificationMessage.CreatedOnFormatDateTime = Infrastructure.Helpers.FormatHelper.FormatDateTime(
                        notificationMessage.CreatedOn.ToString("MM/dd/yyyy"),
                        notificationMessage.CreatedOn.ToString("HH:m:s tt zzz"));

                    return(Json(notificationMessage));
                }

                return(Json(new NotificationMessage()));
            }
            catch (Exception ex)
            {
                return(BadRequestFormatter.BadRequest(this, ex));
            }
        }