Exemple #1
0
        /// <summary>
        /// Map Bom Group View Model to Model.
        /// </summary>
        /// <param name="bomGroupViewModel"></param>
        /// <returns></returns>
        private BomGroup MapBomGroupToModel(BomGroupViewModel bomGroupViewModel)
        {
            var bomGroup = new BomGroup {
                Name = bomGroupViewModel.Name
            };

            if (bomGroupViewModel.BillOfMaterials != null && bomGroupViewModel.BillOfMaterials.Any())
            {
                var bom = new List <BillOfMaterial>();
                foreach (var groupBillOfMaterial in bomGroupViewModel.BillOfMaterials)
                {
                    bom.Add(MapBomToModel(groupBillOfMaterial));
                }
                bomGroup.BillOfMaterials = bom;
            }

            if (bomGroupViewModel.BomItems != null && bomGroupViewModel.BomItems.Any())
            {
                var bomItems = new List <BomItem>();
                foreach (var bomGroupBomItem in bomGroupViewModel.BomItems)
                {
                    bomItems.Add(MapBomItemToModel(bomGroupBomItem));
                }
                bomGroup.BomItems = bomItems;
            }
            return(bomGroup);
        }
Exemple #2
0
        /// <summary>
        /// Map group model to view model
        /// </summary>
        /// <param name="bomGroup"></param>
        /// <returns></returns>
        private BomGroupViewModel MapBomGroupToViewModel(BomGroup bomGroup)
        {
            var bomGroupViewModel = new BomGroupViewModel {
                Name = bomGroup.Name
            };

            if (bomGroup.BillOfMaterials != null && bomGroup.BillOfMaterials.Any())
            {
                var bomViewModel = new List <BillOfMaterialViewModel>();
                foreach (var groupBillOfMaterial in bomGroup.BillOfMaterials)
                {
                    bomViewModel.Add(MapBomToViewModel(groupBillOfMaterial));
                }
                bomGroupViewModel.BillOfMaterials = bomViewModel;
            }

            if (bomGroup.BomItems != null && bomGroup.BomItems.Any())
            {
                var bomItemsViewModel = new List <BomItemViewModel>();
                foreach (var bomGroupBomItem in bomGroup.BomItems)
                {
                    bomItemsViewModel.Add(MapBomItemToViewModel(bomGroupBomItem));
                }
                bomGroupViewModel.BomItems = bomItemsViewModel;
            }
            return(bomGroupViewModel);
        }