コード例 #1
0
        public int SaveConfiguration(Configurations body)
        {
            body.CreatedOn = DateTime.Now;
            List <ConfigurationParts> partsIds = body.ConfigurationParts;

            body.CarId               = body.Car.Id;
            body.CreatedBy           = body.CreatedByNavigation.Id;
            body.Car                 = null;
            body.CreatedByNavigation = null;
            body.ConfigurationParts  = null;

            dbContext.Configurations.Add(body);
            dbContext.SaveChanges();

            foreach (ConfigurationParts cp in partsIds)
            {
                ConfigurationParts temp = new ConfigurationParts
                {
                    ConfigurationId = body.Id,
                    PartId          = cp.Id
                };
                dbContext.ConfigurationParts.Add(temp);
            }
            dbContext.SaveChanges();

            return(body.Id);
        }
コード例 #2
0
        private void PopulateConfigurationParts()
        {
            ConfigurationParts.Clear();
            var commonParts = SelectedBuildFlavor.Components.Where(prt => prt.Included).GroupBy(prt => prt.Key);

            foreach (var entry in commonParts)
            {
                var part = new PlaceableParts()
                {
                    Count   = entry.Count(),
                    Value   = entry.First().Value.ToUpper(),
                    Package = entry.First().PackageName.ToUpper(),
                };

                part.Parts = new ObservableCollection <Component>();

                foreach (var specificPart in entry)
                {
                    var placedPart = SelectedBuildFlavor.Components.Where(cmp => cmp.Name == specificPart.Name && cmp.Key == specificPart.Key).FirstOrDefault();
                    if (placedPart != null)
                    {
                        part.Parts.Add(placedPart);
                    }
                }

                ConfigurationParts.Add(part);
            }

            if (_pnpMachine != null)
            {
                foreach (var part in ConfigurationParts)
                {
                    PnPMachineManager.ResolvePart(_pnpMachine, part);
                }
            }
        }