Beispiel #1
0
        public static string Get(object model)
        {
            var url      = HttpContext.Current.Request.Url.AbsolutePath.ToLowerInvariant();
            var pageMeta = new PageMetaService().GetFor(url);

            if (pageMeta != null && !pageMeta.Title.IsEmpty())
            {
                return(pageMeta.Title);
            }
            if (model == null)
            {
                return(null);
            }
            string title = GetTitle(model as dynamic);

            if (!title.IsEmpty())
            {
                return(title);
            }
            var viewModel = model as IViewModel;

            if (viewModel != null)
            {
                return(viewModel.Title);
            }
            return(title);
        }
Beispiel #2
0
        public static string GetPageTitle()
        {
            var url      = HttpContext.Current.Request.Url.AbsolutePath.ToLowerInvariant();
            var pageMeta = new PageMetaService().GetFor(url);

            if (pageMeta != null)
            {
                return(pageMeta.PageTitle);
            }
            return(null);
        }
Beispiel #3
0
        public static string Get(string url, object model = null)
        {
            url = url.ToLower();
            string description = null;
            string keywords    = null;
            var    service     = new PageMetaService();
            var    pageMeta    = service.GetFor(url);
            var    image       = string.Empty;

            if (pageMeta != null)
            {
                description = pageMeta.Description;
                keywords    = pageMeta.Keywords;
            }
            if (model is NewsVM)
            {
                var newsVM = model.As <NewsVM>();
                description = description ?? StringUtils.RemoveTags(newsVM.News.ShortDescription);
                image       = Urls.Image("News/Small/" + newsVM.News.SmallImage);
            }
            else if (model is CourseVM)
            {
                var courseVM = model.As <CourseVM>();
                var course   = courseVM.Course;
                var meta     = GetCourseMeta(course);
                description = description ?? meta.Item1;
                image       = meta.Item2;
            }
            else if (model is MobileCourseVM)
            {
                var courseVM = model.As <MobileCourseVM>();
                var course   = courseVM.Course;
                var meta     = GetCourseMeta(course);
                description = description ?? meta.Item1;
                image       = meta.Item2;
            }
            else if (model is AboutTrainerVM)
            {
                var aboutTrainerVM = model.As <AboutTrainerVM>();
                description = description ??
                              StringUtils.RemoveTags(StringUtils.GetFirstParagraph(aboutTrainerVM.Description.FirstPart));
                image = Urls.Image("Employee/" + aboutTrainerVM.Employee.Employee.Employee_TC.ToLower() + ".jpg");
            }
            else if (pageMeta == null && model is ExamVM)
            {
                var exam = model.As <ExamVM>().Exam;
                description = "Экзамен № {0} {1} в Специалисте"
                              .FormatWith(exam.Exam_TC, exam.ExamName);
                keywords = "Экзамен, {1}, {0}, Специалист"
                           .FormatWith(exam.Exam_TC, exam.ExamName);
            }
            return(GetMetaTags(keywords, description, image));
        }