Пример #1
0
 public ActionResult Add([Bind(Include = "Id, HorsePower, NewtonMetre, Make, Model, Type, UserInfo")] CarUserViewModel carUserModel)
 {
     if (ModelState.IsValid)
     {
         this._carService.AddCar(carUserModel);
         return(RedirectToAction("Index", "Home"));
     }
     return(View(carUserModel));
 }
Пример #2
0
        public CarUserViewModel GetCarModelWithSimpleUsersList()
        {
            CarUserViewModel       carModel = new CarUserViewModel();
            List <ApplicationUser> users    = new List <ApplicationUser>();


            foreach (var user in this.Context.Users)
            {
                users.Add(user);
            }

            carModel.UsersList = users;
            return(carModel);
        }
Пример #3
0
        public void AddCar(CarUserViewModel model)
        {
            Car cuvm = new Car()
            {
                HorsePower  = model.HorsePower,
                Make        = model.Make,
                Model       = model.Model,
                NewtonMetre = model.NewtonMetre,
                Type        = model.Type
                              //SimpleNotUserId = model.UserInfo
            };

            this.Context.Cars.Add(cuvm);
            this.Context.SaveChanges();
        }
Пример #4
0
        public ActionResult Add()
        {
            CarUserViewModel model = this._carService.GetCarModelWithSimpleUsersList();

            return(this.View(model));
        }