public void SetMakeType(IEnumerable <CarMake> make)
 {
     foreach (var makeType in make)
     {
         MakeType.Add(new SelectListItem()
         {
             Value = makeType.MakeID.ToString(),
             Text  = makeType.Make
         });
     }
 }
Example #2
0
        public void SelectMakeType(GUIStyle style, Action <MakeType> onChangeMakeType)
        {
            EditorGUILayout.LabelField("2. 作成する内容を選択する", style);
            var newMakeType = (MakeType)EditorGUILayout.EnumPopup(MType);

            if (newMakeType != MType)
            {
                MType = newMakeType;
                onChangeMakeType(MType);
            }
        }
        public IActionResult GetVehicleByMakeID(int makeID)
        {
            try
            {
                SqlConnection conn = new SqlConnection(Utils.connectionString);
                SqlCommand    cmd  = new SqlCommand();

                cmd.Connection  = conn;
                cmd.CommandText = "select MakeTypeID, Name[Description] from MakeType where MakeTypeID = @makeID;";

                SqlParameter param = new SqlParameter();

                param.ParameterName = "@makeID";
                param.Value         = makeID;

                cmd.Parameters.Add(param);



                conn.Open();

                DataTable dt = new DataTable();



                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    dt.Load(dr);

                    List <MakeType> carsList = new List <MakeType>();



                    foreach (DataRow row in dt.Rows)
                    {
                        MakeType cars = new MakeType();

                        cars.MakeTypeID  = Convert.ToInt32(row["MakeTypeID"]);
                        cars.Description = Convert.ToString(row["Description"]);

                        carsList.Add(cars);
                    }

                    return(Ok(carsList));
                }
            }
            catch (SqlException sqlEx)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, sqlEx));
            }
        }
Example #4
0
 public Car(
     CarType type,
     MakeType make,
     string model,
     int yearOfMake,
     string color,
     int vin)
 {
     Type       = type;
     Make       = make;
     Model      = model;
     YearOfMake = yearOfMake;
     Color      = color;
     VIN        = vin;
 }
Example #5
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            MakeType = await _context.MakeType.FirstOrDefaultAsync(m => m.ID == id);

            if (MakeType == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Example #6
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            MakeType = await _context.MakeType.FindAsync(id);

            if (MakeType != null)
            {
                _context.MakeType.Remove(MakeType);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Example #7
0
        IStateMachineServiceEditor CreateEditor(MakeType type)
        {
            IStateMachineServiceEditor editor = null;

            switch (type)
            {
            case MakeType.StateNode:
                editor = Resources.Load <StateNodeServiceEditorSettings>("StateNodeServiceEditorSettings");
                break;

            case MakeType.StateMachine:
                editor = Resources.Load <StateMachineServiceEditorSettings>("StateMachineServiceEditorSettings");
                break;
            }

            return(editor);
        }
        public IActionResult GetVehicleMake()
        {
            try
            {
                SqlConnection conn = new SqlConnection(Utils.connectionString);
                SqlCommand    cmd  = new SqlCommand();

                cmd.Connection  = conn;
                cmd.CommandText = "select MakeTypeID, Name[Description] from MakeType;";
                conn.Open();

                DataTable dt = new DataTable();



                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    dt.Load(dr);

                    List <MakeType> makeList = new List <MakeType>();


                    foreach (DataRow row in dt.Rows)
                    {
                        MakeType makeType = new MakeType();

                        //convert for all INT/Date's etc...
                        makeType.MakeTypeID  = Convert.ToInt32(row["MakeTypeID"]);
                        makeType.Description = Convert.ToString(row["Description"]);


                        makeList.Add(makeType);
                    }

                    return(Ok(makeList));
                }
            }
            catch (SqlException sqlEx)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, sqlEx));
            }
        }
        public bool Edit(
            int id,
            MakeType make,
            string model,
            decimal price,
            int quantity,
            int minShutterSpeed,
            int maxShutterSpeed,
            MinIsoType minIso,
            int maxIso,
            bool isFullFrame,
            string videoResolution,
            int lightMetering,
            string description,
            string imageUrl)
        {
            Camera camera = this.dbContext
                            .Cameras
                            .Find(id);

            if (camera == null)
            {
                return(false);
            }

            camera.Make            = make;
            camera.Model           = model;
            camera.Price           = price;
            camera.Quantity        = quantity;
            camera.MinShutterSpeed = minShutterSpeed;
            camera.MaxShutterSpeed = maxShutterSpeed;
            camera.MinIso          = minIso;
            camera.MaxIso          = maxIso;
            camera.IsFullFrame     = isFullFrame;
            camera.VideoResolution = videoResolution;
            camera.LightMetering   = (LightMeteringType)lightMetering;
            camera.Description     = description;
            camera.ImageUrl        = imageUrl;

            this.dbContext.SaveChanges();
            return(true);
        }
        IScriptCreateService CreateScriptService(MakeType type)
        {
            IScriptCreateService scriptService = null;

            switch (type)
            {
            case MakeType.StateNode:
                var stateNodeEditor = Editor as StateNodeServiceEditorSettings;
                scriptService = new StateNodeServiceScriptCreateService()
                {
                    ThisCommand = new StateNodeServiceScriptCreateService.Command()
                    {
                        FilePath    = stateNodeEditor.ScriptPath,
                        ScriptTemp  = stateNodeEditor.ScriptTemp,
                        ServiceName = stateNodeEditor.ServiceName,
                        StateNames  = stateNodeEditor.StateNames
                    }
                };
                break;

            case MakeType.StateMachine:
                var stateMachineEditor = Editor as StateMachineServiceEditorSettings;
                scriptService = new StateMachineServiceScriptCreateService()
                {
                    ThisCommand = new StateMachineServiceScriptCreateService.Command()
                    {
                        FilePath             = stateMachineEditor.ScriptPath,
                        STMScriptTemp        = stateMachineEditor.STMScriptTemp,
                        InstallerScriptTemp  = stateMachineEditor.InstallerScriptTemp,
                        ServiceName          = stateMachineEditor.ServiceName,
                        FirstStateGameObject = stateMachineEditor.FirstStateGameObject
                    }
                };
                break;
            }

            return(scriptService);
        }
        public void Add(
            MakeType make,
            string model,
            decimal price,
            int quantity,
            int minShutterSpeed,
            int maxShutterSpeed,
            MinIsoType minIso,
            int maxIso,
            bool isFullFrame,
            string videoResolution,
            int lightMetering,
            string description,
            string imageUrl,
            string userId)
        {
            this.dbContext
            .Cameras
            .Add(new Camera
            {
                Make            = make,
                Model           = model,
                Price           = price,
                Quantity        = quantity,
                MinShutterSpeed = minShutterSpeed,
                MaxShutterSpeed = maxShutterSpeed,
                MinIso          = minIso,
                MaxIso          = maxIso,
                IsFullFrame     = isFullFrame,
                VideoResolution = videoResolution,
                LightMetering   = (LightMeteringType)lightMetering,
                Description     = description,
                ImageUrl        = imageUrl,
                UserId          = userId
            });

            this.dbContext.SaveChanges();
        }
        IPrefabCreateService CreatePrefabService(MakeType type)
        {
            IPrefabCreateService prefabService = null;

            switch (type)
            {
            case MakeType.StateNode:
                var stateNodeEditor = Editor as StateNodeServiceEditorSettings;
                prefabService = new StateNodeServicePrefabCreateService()
                {
                    ThisCommand = new StateNodeServicePrefabCreateService.Command()
                    {
                        FilePath   = stateNodeEditor.PrefabPath,
                        Settings   = this.Settings,
                        StateNames = stateNodeEditor.StateNames
                    }
                };
                break;

            case MakeType.StateMachine:
                var stateMachineEditor = Editor as StateMachineServiceEditorSettings;
                prefabService = new StateMachineServicePrefabCreateService()
                {
                    ThisCommand = new StateMachineServicePrefabCreateService.Command()
                    {
                        FilePath              = stateMachineEditor.PrefabPath,
                        Settings              = Settings,
                        ServiceName           = stateMachineEditor.ServiceName,
                        FirstStateGameObject  = stateMachineEditor.FirstStateGameObject,
                        prefabInstallSettings = stateMachineEditor.prefabInstallSettings
                    }
                };
                break;
            }

            return(prefabService);
        }
        public void Create(MakeType make,
                           string cameraModel,
                           decimal price,
                           int quantity,
                           string description,
                           bool isFullFrame,
                           IEnumerable <LightMeteringType> lightMetering,
                           MinISOType minISO,
                           int maxISO,
                           int minShutterSpeed,
                           int maxShutterSpeed,
                           string imageUrl,
                           string videoResolution,
                           string userId)
        {
            var camera = new Camera
            {
                Make            = make,
                Model           = cameraModel,
                Price           = price,
                Quantity        = quantity,
                Description     = description,
                IsFullFrame     = isFullFrame,
                LightMetering   = (LightMeteringType)lightMetering.Cast <int>().Sum(),
                MinISO          = minISO,
                MaxISO          = maxISO,
                MinShutterSpeed = minShutterSpeed,
                MaxShutterSpeed = maxShutterSpeed,
                ImageUrl        = imageUrl,
                VideoResolution = videoResolution,
                UserId          = userId
            };

            db.Cameras.Add(camera);
            db.SaveChanges();
        }
        private void EnterNewCar()
        {
            Console.Clear();
            Console.WriteLine("You have chosen to create a new car entry.\n\n" +
                              "What is the make of the car?\n\n" +
                              "1. Toyota\n" +
                              "2. Honda\n" +
                              "3. Chevrolet\n" +
                              "4. Ford\n" +
                              "5. Mercedes-Benz\n" +
                              "6. Jeep\n" +
                              "7. BMW\n" +
                              "8. Subaru\n" +
                              "9. Nissan\n" +
                              "10. Volkswagen\n\n");
            string   makeInput = Console.ReadLine();
            MakeType make      = 0;

            switch (makeInput)
            {
            case "1":
                make = MakeType.Toyota;
                break;

            case "2":
                make = MakeType.Honda;
                break;

            case "3":
                make = MakeType.Chevrolet;
                break;

            case "4":
                make = MakeType.Ford;
                break;

            case "5":
                make = MakeType.MercedesBenz;
                break;

            case "6":
                make = MakeType.Jeep;
                break;

            case "7":
                make = MakeType.BMW;
                break;

            case "8":
                make = MakeType.Subaru;
                break;

            case "9":
                make = MakeType.Nissan;
                break;

            case "10":
                make = MakeType.Volkswagen;
                break;

            default:
                break;
            }

            Console.WriteLine("What is the model of the car?\n");
            string model = Console.ReadLine();

            Console.WriteLine("What year was the car made?\n");
            string yearInputString = Console.ReadLine();
            int    yearOfMake      = Convert.ToInt32(yearInputString);

            Console.WriteLine("What is the type of car?\n\n" +
                              "1. Gas\n" +
                              "2. Electric\n" +
                              "3. Hybrid\n\n");
            string  typeInput = Console.ReadLine();
            CarType type      = 0;

            switch (typeInput)
            {
            case "1":
                type = CarType.Gas;
                break;

            case "2":
                type = CarType.Electric;
                break;

            case "3":
                type = CarType.Hybrid;
                break;

            default:
                break;
            }

            Console.WriteLine("What is the color of the car?\n");
            string color = Console.ReadLine();

            Console.WriteLine("What is the car's VIN?\n\n");
            int vin = Convert.ToInt32(Console.ReadLine());

            Car  newCar   = new Car(type, make, model, yearOfMake, color, vin);
            bool wasAdded = _repo.EnterNewCar(newCar);

            if (wasAdded)
            {
                Console.WriteLine("The car was added!");
            }
            else
            {
                Console.WriteLine("There was an error adding the car. Please try again.");
            }

            Console.WriteLine("Press any key to continue");
            Console.ReadLine();
        }
        private void UpdateCar()
        {
            Console.Clear();

            int        index = 1;
            List <Car> cars  = _repo.GetContents();

            foreach (Car car in cars)
            {
                Console.WriteLine($"{index++}. {car.Make} {car.Model} - {car.YearOfMake} - {car.Color} (VIN {car.VIN})");
            }

            Console.WriteLine("Which VIN would you like to update?\n\n");
            int oldVIN = Convert.ToInt32(Console.ReadLine());

            Car oldCar = new Car();

            Console.WriteLine("You have chosen to update a car entry.\n\n" +
                              "What is the make of the car?\n\n" +
                              "1. Toyota\n" +
                              "2. Honda\n" +
                              "3. Chevrolet\n" +
                              "4. Ford\n" +
                              "5. Mercedes-Benz\n" +
                              "6. Jeep\n" +
                              "7. BMW\n" +
                              "8. Subaru\n" +
                              "9. Nissan\n" +
                              "10. Volkswagen\n\n");
            string   makeInput = Console.ReadLine();
            MakeType make      = 0;

            switch (makeInput)
            {
            case "1":
                make = MakeType.Toyota;
                break;

            case "2":
                make = MakeType.Honda;
                break;

            case "3":
                make = MakeType.Chevrolet;
                break;

            case "4":
                make = MakeType.Ford;
                break;

            case "5":
                make = MakeType.MercedesBenz;
                break;

            case "6":
                make = MakeType.Jeep;
                break;

            case "7":
                make = MakeType.BMW;
                break;

            case "8":
                make = MakeType.Subaru;
                break;

            case "9":
                make = MakeType.Nissan;
                break;

            case "10":
                make = MakeType.Volkswagen;
                break;

            default:
                break;
            }

            Console.WriteLine("What is the model of the car?\n");
            string model = Console.ReadLine();

            Console.WriteLine("What year was the car made?\n");
            string yearInputString = Console.ReadLine();
            int    yearOfMake      = Convert.ToInt32(yearInputString);

            Console.WriteLine("What is the type of car?\n\n" +
                              "1. Gas\n" +
                              "2. Electric\n" +
                              "3. Hybrid\n\n");
            string  typeInput = Console.ReadLine();
            CarType type      = 0;

            switch (typeInput)
            {
            case "1":
                type = CarType.Gas;
                break;

            case "2":
                type = CarType.Electric;
                break;

            case "3":
                type = CarType.Hybrid;
                break;

            default:
                break;
            }

            Console.WriteLine("What is the color of the car?\n");
            string color = Console.ReadLine();

            Console.WriteLine("What is the car's VIN?\n\n");
            int vin = Convert.ToInt32(Console.ReadLine());

            Car newCar = new Car(type, make, model, yearOfMake, color, vin);

            _repo.UpdateCar(oldVIN, newCar);
        }