Ejemplo n.º 1
0
        /// <summary>
        /// Initialize the part design types data for 2010 season.
        /// </summary>
        public void Initialize2010PartDesignTypes()
        {
            var designTypesRepo = this.container.Resolve<IPartDesignTypeRepository>();
            var uow = this.container.Resolve<IUnitOfWork>();

            try
            {
                var dict = designTypesRepo.GetAllInDictionary();

                if (!dict.ContainsKey("Chassis"))
                {
                    PartDesignType chassis = new PartDesignType() { Name = "Chassis" };
                    designTypesRepo.Save(chassis);
                }

                if (!dict.ContainsKey("Wings"))
                {
                    PartDesignType wings = new PartDesignType() { Name = "Wings" };
                    designTypesRepo.Save(wings);
                }

                if (!dict.ContainsKey("Diffuser"))
                {
                    PartDesignType diffuser = new PartDesignType() { Name = "Diffuser" };
                    designTypesRepo.Save(diffuser);
                }

                if (!dict.ContainsKey("Transmission"))
                {
                    PartDesignType transmission = new PartDesignType() { Name = "Transmission" };
                    designTypesRepo.Save(transmission);
                }

                if (!dict.ContainsKey("Clutch"))
                {
                    PartDesignType clutch = new PartDesignType() { Name = "Clutch" };
                    designTypesRepo.Save(clutch);
                }

                if (!dict.ContainsKey("Suspension"))
                {
                    PartDesignType suspension = new PartDesignType() { Name = "Suspension" };
                    designTypesRepo.Save(suspension);
                }

                if (!dict.ContainsKey("Brakes"))
                {
                    PartDesignType brakes = new PartDesignType() { Name = "Brakes" };
                    designTypesRepo.Save(brakes);
                }

                if (!dict.ContainsKey("Electronics"))
                {
                    PartDesignType electronics = new PartDesignType() { Name = "Electronics" };
                    designTypesRepo.Save(electronics);
                }

                if (!dict.ContainsKey("Engine"))
                {
                    PartDesignType engine = new PartDesignType() { Name = "Engine" };
                    designTypesRepo.Save(engine);
                }

                uow.Commit();
            }
            catch
            {
                uow.Rollback();
                throw;
            }
        }
Ejemplo n.º 2
0
        private PartDesign CreateAndAssignPartDesign(string name, string code, IPartDesignRepository partDesignsRepo, PartDesignType designType, Team theTeam)
        {
            PartDesign theDesign = partDesignsRepo.GetByCode(code);
            if (theDesign == null)
            {
                theDesign = new PartDesign()
                {
                    Name = name,
                    Code = code,
                    PartDesignType = designType,
                    Owner = theTeam,
                    DevelopmentState = EDevelopmentState.Finished
                };
                partDesignsRepo.Save(theDesign);
            }

            if (theTeam != null && !theTeam.PartDesigns.Contains(theDesign))
            {
                theTeam.PartDesigns.Add(theDesign);
            }

            return theDesign;
        }