Beispiel #1
0
        public void PostDiscounts()
        {
            var unity = Cms.MvcApplication.Container;
            var simpleValueService = unity.Resolve <SimpleValueService>();

            simpleValueService.EnableTracking();
            var groupService  = unity.Resolve <IGroupService>();
            var courseService = unity.Resolve <ICourseService>();

            if (simpleValueService.LastPostDiscountsDate.AddDays(2) <= DateTime.Today)
            {
                var treeDays = DateTime.Today.AddDays(3);
                var groups   = groupService.GetPlannedAndNotBegin().Where(x => x.Discount > 0 &&
                                                                          x.DateBeg > treeDays).Take(10).ToList();
                var texts      = _.List("Курсы со скидкой на " + DateTime.Today.DefaultString());
                var groupLines = groups.Select(x => {
                    var course = courseService.AllCourseLinks()[x.Course_TC];
                    var link   = Links.CourseLinkAnchor(null, course.UrlName, course.WebName);
                    return("{0} {1} — {2}% скидка".FormatWith(x.DateBeg.ShortString(),
                                                              link.ToFbLink(), x.Discount));
                });
                texts.AddRange(groupLines);
                texts.Add(H.Anchor(SimplePages.FullUrls.GroupDiscounts,
                                   "Все скидки на " + DateTime.Today.DefaultString()).ToFbLink());
                var text = texts.JoinWith("\n");
                Logger.Run(() => new FacebookService(SpecFBToken).PostSpecUpdate(text, null), "postdiscounts");
                simpleValueService.LastPostDiscountsDate = DateTime.Today;
                simpleValueService.SubmitChanges();
            }
        }
Beispiel #2
0
        public override object Get()
        {
            var url  = Links.CourseLinkAnchor(null, Model.Course).AbsoluteHref().GetHref();
            var text =
                ("Чтобы принять участие в семинаре со скидкой {0}, " +
                 "поделитесь ссылкой на него с друзьями в социальных сетях")
                .FormatWith(Htmls2.DiscountText("50%"));

            return(div[
                       JavaScript().Src("/Scripts/Views/Course/seminarsociallink.js?v=3"),
                       Div("attention")[text, br, url],
                       h3["Добавьте ссылку на Вашу публикацию в социальной сети:"],
                       form.Action(Url.Cart().Urls.AddCourseWithSocialLinkPost(null))[
                           InputText("socialurl", "").Id("social-link-control").Style("width:400px;margin-bottom:10px;"), br,
                           Submit("Добавить в корзину").Id("social-submit-button").SetDisabled(true)]]);
        }
Beispiel #3
0
 private static string GetCourseUrl(Group g)
 {
     return(Links.CourseLinkAnchor(null, g.Course).AbsoluteHref().Attribute("href").Value);
 }