public IActionResult Create([Bind("TopicName")] TopicOptionViewModel viewModel) { try { if (ModelState.IsValid) { var topic = new Domain.Model.TopicOption { Id = viewModel.TopicOptionId, Topic = viewModel.TopicName, Items = RepoItem.GetItemsByTopicName(viewModel.TopicName) // .FindAll(p => p.TopicId == (RepoTopi.GetTopicByName(viewModel.TopicName) // .First(p => p.Topic == viewModel.TopicName).Id)), }; RepoTopi.AddTopic(topic); RepoTopi.Save(); return(RedirectToAction(nameof(Index))); } return(View(viewModel)); } catch { return(View(viewModel)); } }
public ActionResult Delete(int id, [BindNever] IFormCollection collection) { try { RepoItem.DeleteItemByTopicId(id); RepoTopi.DeleteTopicById(id); RepoTopi.Save(); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }