Esempio n. 1
0
        /// <summary>
        /// Buys a standard part from a design.
        /// </summary>
        /// <param name="parameters">A string containing the team id which buying, plus the design id, separated with a pipe.</param>
        public void BuyStandardPart(string parameters)
        {
            string[] p = parameters.Split('|');
            if (p.Length < 2)
            {
                throw new ArgumentException("Invalid function parameter. Team id and PartDesign Id expected.");
            }

            int teamId;
            if (!int.TryParse(p[0], out teamId))
            {
                throw new ArgumentException("Invalid function parameter. Team Id expected.");
            }

            int partDesignId;
            if (!int.TryParse(p[1], out partDesignId))
            {
                throw new ArgumentException("Invalid function parameter. PartDesign Id expected.");
            }

            TeamServices teamSvc = new TeamServices();
            var theTeam = teamSvc.GetById(teamId);

            PartDesignServices partDesignSvc = new PartDesignServices();
            var theDesign = partDesignSvc.GetById(partDesignId);

            PartServices partSvc = new PartServices();
            partSvc.BuyStandardPart(theDesign, theTeam);
        }
Esempio n. 2
0
        /// <summary>
        /// Builds a part from a design.
        /// </summary>
        /// <param name="parameters">A string containing the PartDesign Id.</param>
        public void BuildPartFromDesign(string parameters)
        {
            int partDesignId;
            if (!int.TryParse(parameters, out partDesignId))
            {
                throw new ArgumentException("Invalid function parameter. PartDesign Id expected.");
            }

            // PartDesign theDesign
            PartDesignServices partDesignSvc = new PartDesignServices();
            var theDesign = partDesignSvc.GetById(partDesignId);

            PartServices partSvc = new PartServices();
            partSvc.BuildPartFromDesign(theDesign);
        }
Esempio n. 3
0
        /// <summary>
        /// Mounts a part in a car.
        /// </summary>
        /// <param name="parameters">A string containing the part id which mounting, plus the vehicle id, separated with a pipe.</param>
        public void MountPart(string parameters)
        {
            string[] p = parameters.Split('|');
            if (p.Length < 2)
            {
                throw new ArgumentException("Invalid function parameter. Part id and vehicle Id expected.");
            }

            int partId;
            if (!int.TryParse(p[0], out partId))
            {
                throw new ArgumentException("Invalid function parameter. Part Id expected.");
            }

            int vehicleId;
            if (!int.TryParse(p[1], out vehicleId))
            {
                throw new ArgumentException("Invalid function parameter. Vehicle Id expected.");
            }

            PartServices partSvc = new PartServices();
            Part thePart = partSvc.GetById(partId);

            VehicleServices vehicleSvc = new VehicleServices();
            Vehicle theCar = vehicleSvc.GetById(vehicleId);

            partSvc.Mount(thePart, theCar);
        }
Esempio n. 4
0
        /// <summary>
        /// Unmounts a part from a car.
        /// </summary>
        /// <param name="parameters">A string containing the part id wich will be unmounted.</param>
        public void UnmountPart(string parameters)
        {
            int partId;
            if (!int.TryParse(parameters, out partId))
            {
                throw new ArgumentException("Invalid function parameter. Part Id expected.");
            }

            // Part thePart
            PartServices partSvc = new PartServices();
            Part thePart = partSvc.GetById(partId);

            partSvc.Unmount(thePart);
        }