Beispiel #1
0
 private XElement Good(CommonCourseListItemVM item, string desc, string shortDesc)
 {
     try {
         if (shortDesc == null)
         {
             return(null);
         }
         var c     = item.Course;
         var image = Images.Course(c.UrlName).Attribute("src");
         if (image == null)
         {
             return(null);
         }
         return(X("item",
                  X("title", GetShortName(c)),
                  X("description", desc),
                  X("link", CommonConst.SiteRoot +
                    (c.IsTrackBool
                                                 ? _url.Action <TrackController>(x => x.Details(c.UrlName))
                                                 : _url.Action <CourseController>(x => x.Details(c.UrlName))) +
                    StringUtils.GetUtmPart("google", "cpc", "merchant")),
                  X(g + "id", "c" + c.Course_ID),
                  X(g + "image_link", image.Value),
                  X(g + "availability", "in stock"),
                  X(g + "product_type", "Курс"),
                  X(g + "price", (int)item.Prices.First(x => x.IsMain).Price + " RUB"),
                  X(g + "condition", "new")));
     }
     catch (Exception e) {
         Logger.Exception(e, item.Course.Course_ID + " " + item.Course.Course_TC);
         return(null);
     }
 }
Beispiel #2
0
 private XElement Program(Dictionary <string, string> directions, CommonCourseListItemVM item, string desc, string shortDesc)
 {
     try {
         if (shortDesc == null || !item.HasNearestGroupOrWebinar)
         {
             return(null);
         }
         var c   = item.Course;
         var url = CommonConst.SiteRoot +
                   (c.IsTrackBool
                                 ? _url.Action <TrackController>(x => x.Details(c.UrlName))
                                 : _url.Action <CourseController>(x => x.Details(c.UrlName)));
         var type      = c.IsSchool ? "подготовительные курсы" : "повышение квалификации";
         var audiences = c.IsSchool ? "школьники" : "взрослые";
         return(X("program",
                  A("id", c.Course_ID),
                  X("name", StringUtils.RemoveTags(c.WebName)),
                  X("description", StringUtils.SafeSubstring(shortDesc, 800)),
                  X("link", url),
                  c.CourseDirectionA_TC == null
                                 ? null
                                 : X("rubrics", X("rubric", A("id", c.CourseDirectionA_TC), directions[c.CourseDirectionA_TC])),
                  X("type", type),
                  X("audiences", X("audience", audiences)),
                  X("forms",
                    Form(c, item.GetPrice(PriceTypes.Webinar), item.NearestWebinar, true),
                    Form(c, item.GetPrice(PriceTypes.Main), item.NearestGroup, false)
                    )));
     }
     catch (Exception e) {
         Logger.Exception(e, item.Course.Course_ID + " " + item.Course.Course_TC);
         return(null);
     }
 }
Beispiel #3
0
        private XElement Course(CommonCourseListItemVM item, string desc, string shortDesc)
        {
            try {
                if ((desc.IsEmpty() && shortDesc.IsEmpty()) || item.NearestWebinar == null)
                {
                    return(null);
                }
                var groups = GroupService.GetGroupsForCourse(item.Course.Course_TC).Take(15).ToList();

                if (!groups.Any())
                {
                    return(null);
                }
                var c        = item.Course;
                var category = _directions.GetValueOrDefault(c.CourseDirectionA_TC);
                shortDesc = shortDesc ?? category;
                var maxLength    = 240;
                var shortDesc160 = shortDesc.Length > maxLength
                                ? StringUtils.SafeSubstring(shortDesc, maxLength - 3) + "..."
                                        : shortDesc;

                return(X("course",
                         X("id", c.Course_ID),
                         X("name", StringUtils.RemoveTags(c.WebName)),
                         X("short-description", category),
                         X("description", desc),
                         X("tags", X("tag", category)),
                         X("lessons", groups.SelectMany(Lesson))
                         ));
            }
            catch (Exception e) {
                Logger.Exception(e, "course error " + item.Course.Course_ID + " " + item.Course.Course_TC);
                return(null);
            }
        }
Beispiel #4
0
        List <string> CourseData(CommonCourseListItemVM item, string desc, string shortDesc)
        {
            try {
                var date   = DateTime.Today.AddMonths(6);
                var groups = GroupService.GetGroupsForCourse(item.Course.Course_TC)
                             .Where(x => x.DateBeg <= date)
                             .Select(x => x.DateInterval).Distinct().ToList().JoinWith(", ");

                var c = item.Course;

                var url = CommonConst.SiteRoot +
                          (c.IsTrackBool
                                                ? _url.Action <TrackController>(x => x.Details(c.UrlName))
                                                : _url.Action <CourseController>(x => x.Details(c.UrlName)));
                return(_.List(
                           StringUtils.RemoveTags(c.Name),
                           ((int)item.GetPrice(PriceTypes.Corporate)).ToString(),
                           shortDesc,
                           url,
                           groups));
            } catch (Exception e) {
                Logger.Exception(e, "course error " + item.Course.Course_ID + " " + item.Course.Course_TC);
                return(null);
            }
        }
Beispiel #5
0
 private List <string> Good(CommonCourseListItemVM item, string desc, string shortDesc)
 {
     try {
         if (shortDesc == null)
         {
             return(null);
         }
         var c     = item.Course;
         var image = Images.Course(c.UrlName).Attribute("src");
         if (image == null)
         {
             return(null);
         }
         return(_.List(
                    "c" + c.Course_ID,
                    StringUtils.RemoveTags(c.GetShortName()),
                    CommonConst.SiteRoot +
                    (c.IsTrackBool
                                                 ? _url.Action <TrackController>(x => x.Details(c.UrlName))
                                                 : _url.Action <CourseController>(x => x.Details(c.UrlName))),
                    image.Value,
                    image.Value,
                    shortDesc,
                    "«Специалист» при МГТУ им.Баумана",
                    "курсы;обучение;вебинар;семинар"));
     }
     catch (Exception e) {
         Logger.Exception(e, item.Course.Course_ID + " " + item.Course.Course_TC);
         return(null);
     }
 }
Beispiel #6
0
        private XElement Good(CommonCourseListItemVM item, string desc, string shortDesc)
        {
            try {
                if (shortDesc == null)
                {
                    return(null);
                }
                var f     = "False";
                var t     = "True";
                var c     = item.Course;
                var image = Images.Course(c.UrlName).Attribute("src");
                if (image == null)
                {
                    return(null);
                }
                return(X("Good",
                         A("article", "c" + c.Course_ID),
                         A("name", c.WebName),
                         A("cargoRegistered", f),
                         A("isVirtual", t),
                         A("img", image.Value),

                         A("cost", (int)item.Prices.First(x => x.IsMain).Price),
                         A("shortDescription", shortDesc),
                         A("description", desc),
                         A("categories", rootCategory)));
            }
            catch (Exception e) {
                Logger.Exception(e, item.Course.Course_ID + " " + item.Course.Course_TC);
                return(null);
            }
        }
Beispiel #7
0
        public static string TrackPrice(this CommonCourseListItemVM courseListItemVM, string priceType, decimal?newPrice)
        {
            var realFullPrice       = courseListItemVM.GetTrackFullPrice(priceType);
            var pt                  = PriceTypes.IsCorp(priceType) ? PriceTypes.Corporate : PriceTypes.Main;
            var ppPrice             = courseListItemVM.GetTrackFullPrice(pt);
            var intraExtraFullPrice = newPrice * ((decimal)1.8);
            var fullPrice           = PriceTypes.IsIntraExtra(priceType)
                                ? (ppPrice > 0 && ppPrice <= intraExtraFullPrice ?
                                   OrderDetail.FloorToFifty(((decimal)ppPrice) * (decimal)0.95) : intraExtraFullPrice)
                                : realFullPrice;

            return(Htmls2.OldNewPrice(fullPrice, newPrice));
        }