Пример #1
0
        // Site Converter
        public static SiteDTO ToDto(this Community_Showcase_Site item)
        {
            SiteDTO dto = new SiteDTO()
            {
                id           = item.id,
                name         = item.name,
                created_date = item.created_date,
                description  = item.description,
                is_active    = item.is_active,
                thumbnail    = item.thumbnail,
                url          = item.url,
                user_id      = item.user_id
            };

            dto.site_categories = new List <SiteCategoryDTO>();
            foreach (Community_Showcase_SiteCategory site_category in item.Community_Showcase_SiteCategories)
            {
                SiteCategoryDTO siteCategoryDTO = new SiteCategoryDTO()
                {
                    category_id   = site_category.category_id,
                    site_id       = site_category.site_id,
                    site_name     = site_category.Community_Showcase_Site.name,
                    category_name = site_category.Community_Showcase_Category.name
                };
                dto.site_categories.Add(siteCategoryDTO);
            }


            return(dto);
        }
Пример #2
0
        // Site Category Converter
        public static SiteCategoryDTO ToDto(this Community_Showcase_SiteCategory item)
        {
            SiteCategoryDTO dto = new SiteCategoryDTO()
            {
                id          = item.id,
                site_id     = item.site_id,
                category_id = item.category_id,

                site_name     = item.Community_Showcase_Site.name,
                category_name = item.Community_Showcase_Category.name
            };

            return(dto);
        }
Пример #3
0
        public static Community_Showcase_SiteCategory ToItem(this SiteCategoryDTO dto, Community_Showcase_SiteCategory item)
        {
            if (item == null)
            {
                item = new Community_Showcase_SiteCategory();
            }

            if (dto == null)
            {
                return(item);
            }

            item.id          = dto.id;
            item.site_id     = dto.site_id;
            item.category_id = dto.category_id;

            return(item);
        }