// GET: LocHours/Create public ActionResult Manage(int id) { LocHourCats cats = context.LocHourCats.FirstOrDefault(h => h.Id == id); LocationHoursViewModel model = new LocationHoursViewModel { Location = context.Locations .FirstOrDefault(h => h.Id == cats.LocationId), Cats = cats, LocHours = new LocHours() }; return(View(model)); }
// GET: LocHours/Edit/5 public ActionResult Edit(int?id) { LocHours hours = context.LocHours .FirstOrDefault(h => h.Id == id); LocHourCats cats = context.LocHourCats.FirstOrDefault(h => h.Id == hours.LocHourCatsId); LocationHoursViewModel model = new LocationHoursViewModel { Location = context.Locations .FirstOrDefault(h => h.Id == cats.LocationId), Cats = cats, LocHours = hours }; return(View(model)); }