public ActionResult Add(ResourcesAddViewModel viewModel) { ValidateResource(viewModel.Resource); if (ModelState.IsValid) { var resource = viewModel.Resource; _resourcesRepository.Add(resource); TempData["Message"] = "Your resource was successfully added."; return(RedirectToAction("Details", new { id = resource.Id })); } viewModel.Init(Repository, _sectionsRepository); return(View(viewModel)); }