public ActionResult IndexUser(string BrandID, int?id) { ViewBag.BrandID = new SelectList(db.Brand, "Name", "Name"); var viewModel = new GarageViewModels(); viewModel.CarModels = db.Cars.Where(c => c.Owner.Email == User.Identity.Name); if (id != null) { ViewBag.Id_Ad = id.Value; viewModel.AdsModels = db.Advertisements.Where(i => i.CarID == id.Value); viewModel.CarModels = db.Cars.Where(i => i.OwnerId == id.Value).Include(o => o.Advertisement).Include(m => m.Brand); } viewModel.CarModels = db.Cars.Include(c => c.Owner).Where(c => c.Owner.Email == User.Identity.Name).Include(s => s.Advertisement).Include(b => b.Brand); if (!String.IsNullOrEmpty(BrandID)) { viewModel.CarModels = viewModel.CarModels.Where(s => s.Brand.Name.Contains(BrandID)); } return(View(viewModel)); }
public ActionResult IndexUser() { var viewModel = new GarageViewModels(); viewModel.OwnerModels = db.Owners.Where(i => i.Email == User.Identity.Name).Include(s => s.Cars); Console.WriteLine(viewModel.OwnerModels); return(View(viewModel)); }
public ActionResult Index() { var viewModel = new GarageViewModels(); ViewBag.CarId = new SelectList(db.Cars, "Model", "Model"); viewModel.Parts = db.Parts; viewModel.Parts = db.Parts.Include(p => p.Car); return(View(viewModel)); }
public ActionResult Index(int?id) { var viewModel = new GarageViewModels(); viewModel.OwnerModels = db.Owners.Include(s => s.Cars); if (id != null) { ViewBag.Id_Owner = id.Value; viewModel.CarModels = db.Cars.Where(i => i.OwnerId == id.Value).Include(o => o.Advertisement).Include(m => m.Brand); } return(View(viewModel)); }
public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PartsModels partsModels = db.Parts.Find(id); if (partsModels == null) { return(HttpNotFound()); } var viewModel = new GarageViewModels(); viewModel.Parts = db.Parts.Include(p => p.Car); viewModel.OwnerModels = db.Owners.Where(o => o.ID == partsModels.Owner); return(View(viewModel)); }
// GET: PartsModels public ActionResult IndexUser(string BrandID) { var viewModel = new GarageViewModels(); ViewBag.BrandID = new SelectList(db.Brand, "Name", "Name"); ViewBag.CarId = new SelectList(db.Cars, "Model", "Model"); viewModel.OwnerModels = db.Owners.Where(o => o.Email == User.Identity.Name); viewModel.Parts = db.Parts.Include(p => p.Car); if (!String.IsNullOrEmpty(BrandID)) { viewModel.Parts = viewModel.Parts.Where(s => s.Brand.Contains(BrandID)); } return(View(viewModel)); }