Exemple #1
0
        public async Task PostJob(Job jobOpportunity, IUrlHelper urlHelper)
        {
            if (string.IsNullOrWhiteSpace(jobOpportunity?.Title) || jobOpportunity.Id <= 0)
            {
                return;
            }

            var descriptionLength  = 124;
            var trimmedDescription = Regex.Replace(jobOpportunity.Description, "<.*?>", String.Empty).TrimStart();
            var limitedDescription = trimmedDescription.Length > descriptionLength
                ? trimmedDescription.Substring(0, descriptionLength) + "..."
                : trimmedDescription;

            // var action = UrlExtensions.SeoUrl(jobOpportunity.Id, jobOpportunity.Title);
            var action = UrlExtensions.SeoUrl("details", jobOpportunity.Id);

            var payloadObject = new PayloadRequestDto()
            {
                text             = "A new job posting has been created!",
                replace_original = false,
                attachments      = new List <Attachment> {
                    new Attachment {
                        fallback        = "Check the new posted job at " + urlHelper.AbsoluteUrl("details", jobOpportunity.Id, "jobs"),
                        author_name     = jobOpportunity.Company.Name,
                        title           = jobOpportunity.Title,
                        title_link      = urlHelper.AbsoluteUrl("details", jobOpportunity.Id, "jobs"),
                        text            = limitedDescription,
                        thumb_url       = jobOpportunity.Company.LogoUrl,
                        callback_id     = jobOpportunity.Id.ToString(),
                        color           = "#3AA3E3",
                        attachment_type = "default",
                        actions         = new List <AttachmentAction> {
                            new AttachmentAction {
                                name  = "approve",
                                text  = "Approve",
                                style = "primary",
                                type  = "button",
                                value = "approve"
                            }, new AttachmentAction {
                                name  = "reject",
                                text  = "Reject",
                                style = "default",
                                type  = "button",
                                value = "reject"
                            }
                        }
                    }
                }
            };

            await PostNotification(payloadObject, _slackWebhookUrl).ConfigureAwait(false);
        }
Exemple #2
0
        public async Task PostJobResponse(Job jobOpportunity, IUrlHelper urlHelper, string responseUrl, string userId, bool approved)
        {
            if (string.IsNullOrWhiteSpace(jobOpportunity?.Title) || jobOpportunity.Id <= 0)
            {
                return;
            }

            var descriptionLength  = 124;
            var trimmedDescription = Regex.Replace(jobOpportunity.Description, "<.*?>", String.Empty).TrimStart();
            var limitedDescription = trimmedDescription.Length > descriptionLength
                ? trimmedDescription.Substring(0, descriptionLength) + "..."
                : trimmedDescription;

            //var action = UrlExtensions.SeoUrl(jobOpportunity.Id, jobOpportunity.Title);
            var action = UrlExtensions.SeoUrl("details", jobOpportunity.Id);

            var approvedMessage = approved ? "approved" : "rejected";

            var payloadObject = new PayloadRequestDto()
            {
                text             = "A new job posting has been created!",
                replace_original = true,
                attachments      = new List <Attachment> {
                    new Attachment {
                        fallback        = "Check the new posted job at " + urlHelper.AbsoluteUrl("details", jobOpportunity.Id, "jobs"),
                        author_name     = jobOpportunity.Company.Name,
                        title           = jobOpportunity.Title,
                        title_link      = urlHelper.AbsoluteUrl("details", jobOpportunity.Id, "jobs"),
                        text            = limitedDescription,
                        thumb_url       = jobOpportunity.Company.LogoUrl,
                        callback_id     = jobOpportunity.Id.ToString(),
                        color           = "#3AA3E3",
                        attachment_type = "default",
                        fields          = new List <AttachmentField> {
                            new AttachmentField {
                                title  = "",
                                value  = ":ballot_box_with_check: <@" + userId + "> *" + approvedMessage + " this request*",
                                @short = false
                            }
                        }
                    }
                }
            };

            await PostNotification(payloadObject, responseUrl).ConfigureAwait(false);
        }