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)); }
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); }
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(); }
public ActionResult Add() { CarUserViewModel model = this._carService.GetCarModelWithSimpleUsersList(); return(this.View(model)); }