예제 #1
0
        public ActionResult Models()
        {
            var repo = CarMasterRepoFactory.Create();
            AddModelViewModel model = new AddModelViewModel();

            model.SetMakesList(repo.GetAllMakes());
            return(View(model));
        }
예제 #2
0
        public ActionResult AddModel(AddModelViewModel modelToCreate)
        {
            //VM-Model and makeslist
            //Model
            //ModelId, ModelDescription, DateAdded, MakeId
            var repo = CarMasterRepoFactory.Create();

            if (ModelState.IsValid)
            {
                //Model newModel = new Model();
                //modelToCreate.Model.DateAdded = DateTime.Now;
                //m.Model.DateAdded = DateTime.Now;
                //newModel.ModelDescription = m.Model.ModelDescription;
                //newModel.Make.MakeId = m.Model.Make.MakeId;
                repo.CreateModel(modelToCreate.Model);
                return(RedirectToAction("Models"));
            }
            else
            {
                AddModelViewModel result = new AddModelViewModel();
                result.SetMakesList(repo.GetAllMakes());
                return(View(result));
            }
        }