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); }
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); }