Exemplo n.º 1
0
        public ActionResult DoEdit([ModelBinder(typeof(UserModelBinder))] User user, Guid id, HttpPostedFileBase file, FilmInput input)
        {
            var data = FilmsDao.GetFilmWithFullInfo(id);

            input.CopyToData(data, file, CountriesDao, GenresDao, DirectorsDao, ActorsDao);
            FilmsDao.Update(data);

            if (user.HasFavourite(id))
            {
                user.FavFilms.RemoveAll(f => f.ID == id);

                user.FavFilms.Add(data);

                var cookie = new HttpCookie(nameof(User))
                {
                    Value   = JsonConvert.SerializeObject(user),
                    Expires = DateTime.Now.AddYears(1),
                    Path    = "/"
                };

                Response.Cookies.Add(cookie);
            }

            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        public ActionResult Delete([ModelBinder(typeof(UserModelBinder))] User user, Guid id)
        {
            var film = FilmsDao.GetFilmWithFullInfo(id);

            return(View(new FilmView(film)
            {
                IsFav = user.HasFavourite(id)
            }));
        }
Exemplo n.º 3
0
        public ActionResult Edit(Guid id)
        {
            var film = FilmsDao.GetFilmWithFullInfo(id);

            return(View(new FilmInfoContainer()
            {
                Film = new FilmView(film),
                AvailableActors = ActorsDao.GetActorsWithoutFilm(film.ID),
                AvailableDirectors = DirectorsDao.FindAll(),
                AvailableGenres = GenresDao.GetGenresWithoutFilm(film.ID)
            }));
        }