public ActionResult AddHouseToMunicipality(MunicipalityHouseRelation obj) { if (ModelState.IsValid) { dataManager.MunicipalityHouseRelations.Save(obj); return(RedirectToAction("Index")); } return(View(obj)); }
public ActionResult ViewAddressManagers(int?districtId, int?houseId) { ViewBag.AddressType = "месту проживания"; var hasData = false; var district = dataManager.Districts.Get((int?)districtId ?? 0); //Аким if (district != null) { ViewBag.DistrictManager = dataManager.Persons.Get((int?)district.ManagerId ?? 0); ViewBag.District = district; ViewBag.DistrictManagementInfo = new { Manager = dataManager.Persons.Get((int?)district.ManagerId ?? 0), District = district }.ToSafeDynamic(); hasData = true; } var house = dataManager.Houses.Get((int?)houseId ?? 0); //Руководитель МТУ MunicipalityHouseRelation relationMunicipality = house != null ? dataManager.MunicipalityHouseRelations.GetAll().FirstOrDefault(x => x.HouseId == house.Id) : null; if (relationMunicipality != null) { var municipality = dataManager.Municipalities.Get((int?)relationMunicipality.MunicipalityId ?? 0); if (municipality != null) { ViewBag.MunicipalityManagementInfo = new { Manager = dataManager.Persons.Get((int?)municipality.ManagerId ?? 0), Municipality = municipality } }