Exemplo n.º 1
0
        public static NewsItem MapToNewsItem(NewsItemDTO newsItem)
        {
            var result = new NewsItem
            {
                Author     = newsItem.Author,
                Body       = newsItem.Body,
                Created    = newsItem.Created,
                Header     = newsItem.Header,
                PhotoURL   = newsItem.PhotoURL,
                Id         = newsItem.Id,
                ChartItems = newsItem.ChartItems,
                TotalLikes = newsItem.TotalLikes
            };

            result.Employees = new List <Employee>();
            if (newsItem.EmployeeNewsItems != null)
            {
                foreach (EmployeeNewsItem c in newsItem.EmployeeNewsItems)
                {
                    result.Employees.Add(new Employee {
                        Id = c.EmployeeId
                    });
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        public static NewsItemDTO MapToNewsItemDto(NewsItem newsItem)
        {
            var result = new NewsItemDTO();

            result.EmployeeNewsItems = new List <EmployeeNewsItem>();
            if (newsItem.Employees != null)
            {
                foreach (Employee c in newsItem.Employees)
                {
                    result.EmployeeNewsItems.Add(
                        new EmployeeNewsItem
                    {
                        NewsItemId = newsItem.Id,
                        EmployeeId = c.Id
                    });
                }
            }

            result.Author     = newsItem.Author;
            result.Body       = newsItem.Body;
            result.Created    = newsItem.Created;
            result.Header     = newsItem.Header;
            result.PhotoURL   = newsItem.PhotoURL;
            result.Id         = newsItem.Id;
            result.ChartItems = newsItem.ChartItems;
            result.TotalLikes = newsItem.TotalLikes;
            result.Employees  = newsItem.Employees;
            return(result);
        }