public ActionResult Show(int Id) { var obj = dataManager.Houses.Get(Id); var model = new HouseViewModel { House = obj, Street = dataManager.Streets.Get((int?)obj.StreetId ?? 0), Manager = dataManager.Persons.Get((int?)obj.ManagerId ?? 0), Precinct = dataManager.Precincts.Get(obj.PrecinctId ?? 0) }; ViewBag.Persons = from p in dataManager.Persons.GetAll() where p.HouseId == obj.Id select p; var relationMunicipality = dataManager.MunicipalityHouseRelations.GetAll().FirstOrDefault(x => x.HouseId == Id); if(relationMunicipality != null) { ViewBag.Municipality = dataManager.Municipalities.Get(relationMunicipality.MunicipalityId.HasValue ? relationMunicipality.MunicipalityId.Value : 0); } return View(model); }
public ActionResult Delete(int Id) { var obj = dataManager.Houses.Get(Id); var model = new HouseViewModel { House = obj, Street = dataManager.Streets.Get((int?)obj.StreetId ?? 0) }; return View(model); }