Example #1
0
        //
        // GET: /Movies/Create
        public ActionResult Create()
        {
            var m = new M2M.ViewModels.MovieCreateViewModel();

            m.Tags = tagRepository.All.ToList<Tag>();
            return View(m);
        }
Example #2
0
        public ActionResult Create(Movie movie, FormCollection MovieForm)
        {
            if (ModelState.IsValid) {

                //how to add tags to this movie object? I am getting user selected tag ids posted back
                //movie.Tags = new List<Tag>();
                foreach (var tag in MovieForm["Tags"].Split(','))
                {
                    var _tag = new Tag { tagID = Convert.ToInt32(tag)};

                    //movie.Tags is null

                    movie.Tags.Add(_tag);
                }

                movieRepository.InsertOrUpdate(movie);
                movieRepository.Save();
                return RedirectToAction("Index");
            } else {
                var m = new M2M.ViewModels.MovieCreateViewModel();

                m.Tags = tagRepository.All.ToList<Tag>();
                return View(m);
            }
        }
Example #3
0
        //
        // GET: /Movies/Edit/5
        public ActionResult Edit(int id)
        {
            var model = new M2M.ViewModels.MovieCreateViewModel();
            var eMovie = movieRepository.Find(id);

            model.Movie = eMovie;
            model.Tags = eMovie.Tags.ToList<Tag>();
            return View(model);
        }