public IActionResult Edit([FromRoute] int id, [Bind("LocationName")] StoreViewModel viewModel) { try { if (ModelState.IsValid) { Domain.Model.Store store = RepoStore.GetStoreById(id); store.Name = viewModel.LocationName; store.Items = RepoItem.GetItemsByStoreName(viewModel.LocationName) .FindAll(p => p.StoreId == (RepoStore.GetStoresByName(viewModel.LocationName) .First(p => p.Name == viewModel.LocationName).Id)); RepoStore.UpdateStore(store); RepoStore.Save(); return(RedirectToAction(nameof(Index))); } return(View(viewModel)); } catch (Exception) { return(View(viewModel)); } }