Beispiel #1
0
        public EntityCommonVM(IEntityCommonInfo entity)
        {
            Entity = entity;

            EntityWithTags =
                new List <EntityWithList <IEntityCommonInfo, IEntityCommonInfo> >();
        }
Beispiel #2
0
 public static TagImg Entity(IEntityCommonInfo entity)
 {
     if (entity is Employee)
     {
         return(Employee(entity.UrlName).Alt(entity.Name));
     }
     return(Image(entity.GetType().Name + "/" + GetTrueUrlName(entity.UrlName) + ".jpg")
            .Alt(entity.Name));
 }
Beispiel #3
0
        public JsonSection EntityJson(IEntityCommonInfo x)
        {
            var tp    = x.GetType();
            var type  = SiteObject.TypeTableNames[tp];
            var id    = LinqToSqlUtils.GetPK(x);
            var count = Counts().GetValueOrDefault(Tuple.Create(type, id.ToString()));
            var name  = GetName(type, id);

            return(new JsonSection(type, id, x.UrlName, count, name));
        }
Beispiel #4
0
        public byte GetRank(IEntityCommonInfo entity)
        {
            var url  = GetUrl(entity);
            var rank = PageRanks.GetValueOrDefault(url);

            if (rank == 0)
            {
                return(5);
            }
            return(rank);
        }
Beispiel #5
0
        public static List <string> GetGallaryFiles(IEntityCommonInfo entity, string folder)
        {
            var gallaryFolder = Urls.SysRoot + Urls.ImageFolder +
                                entity.GetType().Name + "/" + folder + "/" + entity.UrlName;

            if (!Directory.Exists(gallaryFolder))
            {
                return(new List <string>());
            }
            var files = Directory.GetFiles(gallaryFolder, "*.jpg", SearchOption.AllDirectories);

            return(files.ToList());
        }
Beispiel #6
0
        string GetUrl(IEntityCommonInfo entity)
        {
            var template = "/{0}/{1}";

            if (entity is SiteTerm)
            {
                template = "/dictionary/definition/{1}";
            }
            if (entity is Product)
            {
                template += "-courses";
            }
            return(template.FormatWith(entity.GetType().Name, entity.UrlName).ToLowerInvariant());
        }
Beispiel #7
0
        public static string Gallary(IEntityCommonInfo entity, bool withSlider = false, string folder = "Gallery",
                                     string filter = "")
        {
            var files = GetGallaryFiles(entity, folder);

            if (!files.Any())
            {
                return(null);
            }
            var result = new List <string>();

            if (!filter.IsEmpty())
            {
                files = files.Where(x => x.Contains(filter)).ToList();
            }
            var imageDescs = new ImageMetas().Descs();

            foreach (var imageFile in files.Select(x => x.Replace('\\', '/'))
                     .Where(x => !x.ToLowerInvariant().EndsWith("-s.jpg")))
            {
                var imageUrl      = Urls.SysToWeb(imageFile).ToLowerInvariant();
                var smallImageUrl = GetSmallImageUrl(imageUrl);
                var name          = Path.GetFileName(Path.GetDirectoryName(imageFile)) + "/" + Path.GetFileName(imageFile);
                var alt           = imageDescs.GetValueOrDefault(name.ToLower());
                var tagA          = H.Anchor(imageUrl,
                                             H.Img(smallImageUrl).Alt(alt).ToString())
                                    .Class("fancy-box").Rel("entity-fancy-box").Style("padding:5px");
                result.Add(tagA.ToString());
            }

            if (!withSlider || result.Count <= 3)
            {
                return(result.JoinWith("").Tag("div"));
            }
            return(CommonSiteHtmls.Carousel(result.CutInPartCount(3)
                                            .Select(x => H.span[x.JoinWith("")].Style("margin:0 20px").Class("fit-width-item")), true).ToString());
        }
Beispiel #8
0
 public VendorVM(IEntityCommonInfo entity) : base(entity)
 {
 }
Beispiel #9
0
 public SubSectionWithNote(IEntityCommonInfo entity, string note)
 {
     Entity = entity;
     Note   = note;
 }
Beispiel #10
0
 public static TagBuilder EntitySmall(IEntityCommonInfo entity)
 {
     return(Root(entity.GetType().Name + "/Small/" + GetTrueUrlName(entity.UrlName) + ".gif")
            .Size(70, 70).Class("ico"));
 }
Beispiel #11
0
        /*   public bool ShowMainPageRightColumn
         * {
         * get
         * {
         *
         * var simplePage = Entity;
         * if (simplePage.SysName == SimplePages.Center)
         *  return true;
         * var rootParent = simplePage.RootMainParent;
         * return rootParent != null && rootParent.SysName == SimplePages.Center;
         * }
         * }*/

        public SimplePageVM(IEntityCommonInfo entity) : base(entity)
        {
            Description         = new TextWithInfoTags(entity.Description);
            Controls            = new List <Control>();
            RightColumnControls = new List <Control>();
        }