public FakeMoviesRepository()
        {
            var firstCategory = new Category { Name = "C_Category" };
            var secondCategory = new Category { Name = "A_Category" };

            _movies = new List<Movie>
                          {
                              new Movie
                                  {
                                      Id = Guid.NewGuid(),
                                      Title = "C_Movie",
                                      Category = firstCategory
                                  },
                              new Movie
                                  {
                                      Id = Guid.NewGuid(),
                                      Title = "A_Movie",
                                      Category = firstCategory
                                  },
                              new Movie
                                  {
                                      Id = Guid.NewGuid(),
                                      Title = "B_Movie",
                                      Category = secondCategory
                                  }
                          };
        }
 public void SaveOrUpdate(Category category)
 {
     if(_categories.Contains(category)) {
         var index = _categories.IndexOf(category);
         _categories.Remove(category);
         _categories.Insert(index, category);
     }
     else {
         _categories.Add(category);
     }
 }
        protected override void BindProperty(ControllerContext controllerContext,
                                             ModelBindingContext bindingContext,
                                             PropertyDescriptor propertyDescriptor)
        {
            if (propertyDescriptor.Name == CategoryPDN) {
                var input = controllerContext.HttpContext.Request.Form[CategoryKey];
                var category = new Category { Id = Guid.Parse(input) };
                propertyDescriptor.SetValue(bindingContext.Model, category);

                return;
            }

            base.BindProperty(controllerContext, bindingContext, propertyDescriptor);
        }
 public void Delete(Category category)
 {
     _categories.Remove(category);
 }
        public void SaveOrUpdate(Category category)
        {
            Check.Require(category != null);

            Session.SaveOrUpdate(category);
        }
        public void Delete(Category category)
        {
            Check.Require(category != null);

            Session.Delete(category);
        }
        public ActionResult EditCategory(Category category)
        {
            if (ModelState.IsValid) {
                _categoriesRepository.SaveOrUpdate(category);

                TempData["message"] = string.Format("{0} has been saved", category.Name);

                return RedirectToAction("Categories");
            }

            var viewModel = new AdminEditCategoryViewModel
                                {
                                    Category = category
                                };

            return View(viewModel);
        }