コード例 #1
0
        public ActionResult AddModel()
        {
            SalesIndexModelsVM VM = new SalesIndexModelsVM();
            var models            = new VehicleModelRepositoryADO();
            var makeRepo          = new MakeRepositoryADO();

            VM.SetAvailableMakes(makeRepo.ReadAllMakes());
            VM.Models = models.ReadAllModel();

            return(View(VM));
        }
コード例 #2
0
        public ActionResult AddModel(SalesIndexModelsCM form)
        {
            if (ModelState.IsValid)
            {
                VehicleModels model = new VehicleModels();
                var           repo  = new VehicleModelRepositoryADO();
                model.Model      = form.Model;
                model.Make       = form.Make;
                model.DateAdded  = form.DateAdded;
                model.EmployeeId = form.EmployeeId;
                repo.CreateModel(model);

                return(RedirectToAction("Index"));
            }
            else
            {
                SalesIndexModelsVM VM = new SalesIndexModelsVM();
                var models            = new VehicleModelRepositoryADO();
                VM.Models = models.ReadAllModel();

                VM.Form = form;
                return(View(VM));
            }
        }