示例#1
0
        /// <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;
            }

            var territoryDto = new TerritoryDto();
            territoryDto.Id = territory.Id;
            territoryDto.RegionBelongingTo = RegionDto.Create(territory.RegionBelongingTo);
            territoryDto.Description = territory.Description;

            foreach (var employee in territory.Employees)
            {
                territoryDto.Employees.Add(EmployeeDto.Create(employee));
            }

            return territoryDto;
        }
示例#2
0
        /// <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);
            }

            var territoryDto = new TerritoryDto();

            territoryDto.Id = territory.Id;
            territoryDto.RegionBelongingTo = RegionDto.Create(territory.RegionBelongingTo);
            territoryDto.Description       = territory.Description;

            foreach (var employee in territory.Employees)
            {
                territoryDto.Employees.Add(EmployeeDto.Create(employee));
            }

            return(territoryDto);
        }