/// <summary> /// Transfers the territory entity's property values to the DTO. /// Strongly consider Jimmy Bogard's AutoMapper (http://automapper.codeplex.com/) /// for doing this kind of work in a more automated fashion. /// </summary> public static TerritoryDto Create(Territory territory) { if (territory == null) return null; TerritoryDto territoryDto = new TerritoryDto(); territoryDto.Id = territory.Id; territoryDto.RegionBelongingTo = RegionDto.Create(territory.RegionBelongingTo); territoryDto.Description = territory.Description; foreach (Employee employee in territory.Employees) { territoryDto.Employees.Add(EmployeeDto.Create(employee)); } return territoryDto; }
/// <summary> /// Transfers the territory entity's property values to the DTO. /// Strongly consider Jimmy Bogard's AutoMapper (http://automapper.codeplex.com/) /// for doing this kind of work in a more automated fashion. /// </summary> public static TerritoryDto Create(Territory territory) { if (territory == null) { return(null); } TerritoryDto territoryDto = new TerritoryDto(); territoryDto.Id = territory.Id; territoryDto.RegionBelongingTo = RegionDto.Create(territory.RegionBelongingTo); territoryDto.Description = territory.Description; foreach (Employee employee in territory.Employees) { territoryDto.Employees.Add(EmployeeDto.Create(employee)); } return(territoryDto); }