public async Task <IActionResult> Add(AddBuildingViewModel model) { if (ModelState.IsValid) { RenovationCompany renovationCompany = _manager.RenovatoinCompanyRepository.Get(model.Id); Building building = _manager.BuildingRepository.Get(model.BuildingId); renovationCompany.Buildings.Add(building); _manager.RenovatoinCompanyRepository.Update(renovationCompany); return(Redirect("~/admin/Companyprocess/show?id=" + model.Id)); } return(View(model)); }
public async Task <IActionResult> Remove(AddBuildingViewModel model) { if (ModelState.IsValid) { RenovationCompany renovationCompany = _manager.RenovatoinCompanyRepository.Get(model.Id); Building building = _manager.BuildingRepository.Get(model.BuildingId); Building building_delete = new Building(); foreach (Building loc_building in renovationCompany.Buildings) { if (loc_building.Id == building.Id) { building_delete = loc_building; } } renovationCompany.Buildings.Remove(building_delete); _manager.RenovatoinCompanyRepository.Update(renovationCompany); return(Redirect("~/admin/Companyprocess/show?id=" + model.Id)); } return(View(model)); }