Beispiel #1
0
        public static string GetXmlString(IEnumerable <RefList> refLists, UrlHelper urlHelper)
        {
            var xmlns = XNamespace.Get("http://www.sitemaps.org/schemas/sitemap/0.9");
            var root  = new XElement(xmlns + "urlset");

            var urls = new List <string>();

            urls.Add(urlHelper.AbsoluteUrl("~/"));

            var baseUrl     = urlHelper.AbsoluteUrl("~/lists/");
            var refListUrls = refLists.Select(l => baseUrl + l.Id);

            urls.AddRange(refListUrls);

            foreach (var url in urls)
            {
                var elem = new XElement(
                    xmlns + "url",
                    new XElement(xmlns + "loc", url),
                    new XElement(xmlns + "changefreq", "daily")
                    );
                root.Add(elem);
            }

            using (var ms = new MemoryStream())
            {
                using (StreamWriter writer = new StreamWriter(ms, Encoding.UTF8))
                {
                    root.Save(writer);
                }

                return(Encoding.UTF8.GetString(ms.ToArray()));
            }
        }
Beispiel #2
0
        public async Task PostNewJobOpportunity(JobOpportunity jobOpportunity, UrlHelper urlHelper)
        {
            if (string.IsNullOrWhiteSpace(jobOpportunity?.Title) || jobOpportunity.Id <= 0)
            {
                return;
            }

            var length  = 80;
            var hashtag = string.Empty;

            if (jobOpportunity.IsRemote)
            {
                length  = 64;
                hashtag = " #weworkremotely";
            }

            var title = jobOpportunity.Title.Length > length
                ? jobOpportunity.Title.Substring(0, length)
                : jobOpportunity.Title;

            var action  = UrlHelperExtensions.SeoUrl(jobOpportunity.Id, jobOpportunity.Title);
            var url     = urlHelper.AbsoluteUrl(action, "jobs");
            var message = $"Se busca: {title}{hashtag} {url}";

            await PostTweet(message).ConfigureAwait(false);
        }
Beispiel #3
0
        public static MvcHtmlString Facebook(this UrlHelper helper, string id)
        {
            var url = helper.AbsoluteUrl("~/lists") + "/" + id;

            return(new MvcHtmlString(
                       "http://www.facebook.com/share.php?u=" + url
                       ));
        }
Beispiel #4
0
        public static MvcHtmlString GooglePlus(this UrlHelper helper, string id)
        {
            var url = helper.AbsoluteUrl("~/lists") + "/" + id;

            return(new MvcHtmlString(
                       "https://plus.google.com/share?url=" + url + "&hl=ja"
                       ));
        }
Beispiel #5
0
        public static MvcHtmlString Twitter(this UrlHelper helper, string id, string title)
        {
            var url = helper.AbsoluteUrl("~/lists") + "/" + id;

            return(new MvcHtmlString(
                       "https://twitter.com/intent/tweet?url=" + url + "&text=" + helper.Encode(title) + "&lang=ja"
                       ));
        }