Example #1
0
        public static DataTransferObject.CategoryDto MapToDto(this DataObjects.NewsCategory item)
        {
            if (item == null) return null;

            var itemDto = new DataTransferObject.CategoryDto ();
                itemDto.NewsCategoryId = item.NewsCategoryId;
                itemDto.Name = item.Name;
                itemDto.ParentCategory = item.ParentCategory.MapToDto();
                itemDto.ChildCategories = item.ChildCategories.Select(x => x.MapToDto());

            return itemDto;
        }
Example #2
0
        public static DataTransferObject.CategoryDto MapToDto(this DataObjects.NewsCategory item)
        {
            if (item == null)
            {
                return(null);
            }

            var itemDto = new DataTransferObject.CategoryDto();

            itemDto.NewsCategoryId  = item.NewsCategoryId;
            itemDto.Name            = item.Name;
            itemDto.ParentCategory  = item.ParentCategory.MapToDto();
            itemDto.ChildCategories = item.ChildCategories.Select(x => x.MapToDto());

            return(itemDto);
        }
Example #3
0
        public static DataObjects.NewsCategory MapFromDto(this DataTransferObject.CategoryDto itemDto)
        {
            if (itemDto == null)
            {
                return(null);
            }

            var item = new DataObjects.NewsCategory();

            item.NewsCategoryId = itemDto.NewsCategoryId;
            item.Name           = itemDto.Name;
            item.ParentCategory = itemDto.ParentCategory.MapFromDto();
            if (itemDto.ChildCategories != null)
            {
                item.ChildCategories.ReplaceRange(itemDto.ChildCategories.Select(x => x.MapFromDto()));
            }

            return(item);
        }