public ActionResult Edit(ResourcesEditViewModel viewModel)
        {
            ValidateResource(viewModel.Resource);

            if (ModelState.IsValid)
            {
                var resource = viewModel.Resource;
                _resourcesRepository.Update(resource);

                TempData["Message"] = "Your resource was successfully added.";

                return(RedirectToAction("Details", new { id = resource.Id }));
            }

            viewModel.Init(Repository, _sectionsRepository);

            return(View(viewModel));
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var resource = _resourcesRepository.Get((int)id);

            if (resource == null)
            {
                return(HttpNotFound());
            }

            var viewModel = new ResourcesEditViewModel()
            {
                Resource = resource
            };

            viewModel.Init(Repository, _sectionsRepository);

            return(View(viewModel));
        }