public async Task <IActionResult> EditPost(int?id) { if (id == null) { return(NotFound()); } var shelterToUpdate = await _shelterRepository.GetShelterByIDWithoutIncludeAndAsNoTracking(id); if (await TryUpdateModelAsync <Shelter>(shelterToUpdate, "", c => c.Name, c => c.MaxPlaces, c => c.Places, c => c.IsOpen, c => c.Description, c => c.IdRegion)) { try { await _shelterRepository.SaveChangesAsync(); } catch (DbUpdateException ex) { ModelState.AddModelError(String.Empty, "Nie można zapisać zmian."); } return(RedirectToAction(nameof(Index))); } PopulateShelter(shelterToUpdate.IdRegion); return(View(shelterToUpdate)); }