public async Task HandlePageCallback(SlackAction slackAction)
        {
            PageCallbackId pageCallbackId = PageCallbackId.FromJson(slackAction.CallbackId);

            GetCacheItemResult result = await _mediator.Send(new GetCacheItem(pageCallbackId.CacheItemId));

            int page = 1;

            page = Convert.ToInt32(pageCallbackId.Page);

            switch (slackAction.Actions.First().Value)
            {
            case "nextpage":
                page++;
                break;

            case "prevpage":
                page--;
                break;
            }

            dynamic notesAttachment = _attachmentGenerator.GenerateAttachment(result.Notes, pageCallbackId.CacheItemId, page);

            await _disappearingSlackMessageProvider.SendDisappearingSlackUpdate(
                channel : slackAction.Channel.Id,
                ts : slackAction.MessageTs,
                attachment : (string)notesAttachment,
                text : "");
        }
        public override string GenerateAttachment(IEnumerable <Note> notes, string cacheItemId, int page = 1)
        {
            if (page < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(page));
            }

            int totalPages = GetTotalPageCount(notes.Count(), Constants.Constants.ReturnedNotesMaxReview);

            int rangeStart = GetPagedItemOffsetStart(page, Constants.Constants.ReturnedNotesMaxReview);

            int pageItemCount = GetPageItemCount(notes.Count(), rangeStart, Constants.Constants.ReturnedNotesMaxReview);

            List <SlackAttachment> listOfAttachments = new List <SlackAttachment>();

            foreach (int i in Enumerable.Range(rangeStart, pageItemCount))
            {
                SlackAttachmentAction slackAction = new SlackAttachmentAction()
                {
                    Name  = "option",
                    Text  = "Delete",
                    Type  = "button",
                    Value = "delete"
                };

                DeleteCallbackId deleteCallbackId = new DeleteCallbackId(
                    Constants.Constants.ActionNameReviewSelection,
                    Constants.Constants.CallbackIdTypeNote,
                    notes.ElementAt(i).DocumentId);

                SlackAttachment slackAttachment = new SlackAttachment()
                {
                    Text       = notes.ElementAt(i).Text,
                    Fallback   = Constants.Constants.MessagePleaseUpgrade,
                    Actions    = new SlackAttachmentAction[] { slackAction },
                    CallbackId = deleteCallbackId.ToJson(),
                    Ts         = notes.ElementAt(i).Timestamp
                };

                listOfAttachments.Add(slackAttachment);
            }

            List <SlackAttachmentAction> slackAttachmentActions = new List <SlackAttachmentAction>();

            if (totalPages > page)
            {
                SlackAttachmentAction slackAction = new SlackAttachmentAction()
                {
                    Name  = "page",
                    Text  = "Next Page",
                    Type  = "button",
                    Value = "nextpage"
                };

                slackAttachmentActions.Add(slackAction);
            }

            if (page > 1)
            {
                SlackAttachmentAction slackAction = new SlackAttachmentAction()
                {
                    Name  = "page",
                    Text  = "Prev Page",
                    Type  = "button",
                    Value = "prevpage"
                };

                slackAttachmentActions.Add(slackAction);
            }

            if (slackAttachmentActions.Any())
            {
                PageCallbackId pageCallbackId = new PageCallbackId(
                    Constants.Constants.ActionNameReviewSelection,
                    Constants.Constants.CallbackIdTypePage,
                    page.ToString(),
                    cacheItemId);

                SlackAttachment slackAttachment = new SlackAttachment()
                {
                    Fallback   = Constants.Constants.MessagePleaseUpgrade,
                    Actions    = slackAttachmentActions.ToArray <SlackAttachmentAction>(),
                    CallbackId = pageCallbackId.ToJson(),
                    Color      = GetRandomHexColour()
                };

                listOfAttachments.Add(slackAttachment);
            }

            return(JsonConvert.SerializeObject(listOfAttachments));
        }