Пример #1
0
        public IActionResult Add(int id)
        {
            AddModViewModel addModViewModel = new AddModViewModel();

            addModViewModel.CarID = id;
            Car myCar = context.Cars.Where(x => x.ID == id).FirstOrDefault();

            addModViewModel.CarName = myCar.Make + " " + myCar.Model + " " + myCar.Year;
            return(View(addModViewModel));
        }
Пример #2
0
        public IActionResult Add(AddModViewModel addModViewModel)
        {
            if (ModelState.IsValid)
            {
                Mod newMod = new Mod()
                {
                    CarID          = addModViewModel.CarID,
                    ModName        = addModViewModel.ModName,
                    ModDescription = addModViewModel.ModDescription,
                    ModDate        = addModViewModel.ModDate,
                    ModCost        = addModViewModel.ModCost
                };
                context.Mods.Add(newMod);
                context.SaveChanges();
                //HttpContext.Session.SetInt32("userID", newUser.ID);


                return(Redirect("/Home/MainPage"));
            }
            else
            {
                return(View());
            }
        }