Esempio n. 1
0
        public ActionResult Create()
        {
            var viewModel = new CreateAndEditFilmViewModel
            {
                Certificates = _unitOfWork.Certificates.GetAll(),
                Countries    = _unitOfWork.Countries.GetAll(),
                Directors    = _unitOfWork.Directors.GetAll(),
                Languages    = _unitOfWork.Languages.GetAll(),
                Studios      = _unitOfWork.Studios.GetAll()
            };

            return(View(viewModel));
        }
Esempio n. 2
0
        public ActionResult Edit(int id, CreateAndEditFilmViewModel filmVM)
        {
            if (ModelState.IsValid)
            {
                var filmToUpdate = _unitOfWork.Films.Get(id);

                Mapper.Map(filmVM, filmToUpdate);

                _unitOfWork.Complete();

                return(RedirectToAction("Index"));
            }

            return(View(filmVM));
        }
Esempio n. 3
0
        public ActionResult Create(CreateAndEditFilmViewModel filmVM)
        {
            if (ModelState.IsValid)
            {
                var filmToAdd = Mapper.Map <CreateAndEditFilmViewModel, Film>(filmVM);

                _unitOfWork.Films.Add(filmToAdd);
                _unitOfWork.Complete();

                return(RedirectToAction("Index"));
            }

            filmVM.Certificates = _unitOfWork.Certificates.GetAll();
            filmVM.Countries    = _unitOfWork.Countries.GetAll();
            filmVM.Directors    = _unitOfWork.Directors.GetAll();
            filmVM.Languages    = _unitOfWork.Languages.GetAll();
            filmVM.Studios      = _unitOfWork.Studios.GetAll();


            return(View(filmVM));
        }