示例#1
0
        //DataObjects.NewsToTags
        //DataObjects.Tag
        public static DataTransferObject.NewsDto MapToDto(this DataObjects.News item)
        {
            if (item == null) return null;

            var itemDto = new DataTransferObject.NewsDto ();
                itemDto.NewsId = item.NewsId;
                itemDto.Title = item.Title;
                itemDto.Anounce = item.Anounce;
                itemDto.Text = item.Text;
                itemDto.Status = item.Status.ToString();
                itemDto.Category = item.Category.MapToDto();
                itemDto.Created = item.Created;
                itemDto.Author = item.Author.Login;
                itemDto.Tags = item.NewsToTags.Select(p => p.Tag.Name);

            return itemDto;
        }
示例#2
0
        public static DataObjects.News MapFromDto(this DataTransferObject.NewsDto itemDto)
        {
            if (itemDto == null)
            {
                return(null);
            }

            var item = new DataObjects.News();

            item.NewsId   = itemDto.NewsId.HasValue ? itemDto.NewsId.Value : default(System.Guid);
            item.Title    = itemDto.Title;
            item.Anounce  = itemDto.Anounce;
            item.Text     = itemDto.Text;
            item.Status   = (DataObjects.Attributes.StatusEnum)System.Enum.Parse(typeof(DataObjects.Attributes.StatusEnum), itemDto.Status);
            item.Category = itemDto.Category.MapFromDto();
            item.Created  = itemDto.Created;

            return(item);
        }
示例#3
0
//DataObjects.NewsToTags
//DataObjects.Tag
        public static DataTransferObject.NewsDto MapToDto(this DataObjects.News item)
        {
            if (item == null)
            {
                return(null);
            }

            var itemDto = new DataTransferObject.NewsDto();

            itemDto.NewsId   = item.NewsId;
            itemDto.Title    = item.Title;
            itemDto.Anounce  = item.Anounce;
            itemDto.Text     = item.Text;
            itemDto.Status   = item.Status.ToString();
            itemDto.Category = item.Category.MapToDto();
            itemDto.Created  = item.Created;
            itemDto.Author   = item.Author.Login;
            itemDto.Tags     = item.NewsToTags.Select(p => p.Tag.Name);

            return(itemDto);
        }