public ActionResult Cart(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            MoviesTable moviesTable = db.MoviesTable.Find(id);

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

            MoviesVM mv = new MoviesVM();

            mv.Title = moviesTable.Title;
            mv.Price = moviesTable.Price;
            Calc cl = new Calc();

            mv.SalesTax = cl.GetTax(moviesTable.Price);
            mv.Total    = cl.GetTotal(moviesTable.Price);

            return(View(mv));


            ////ViewBag.Tax = moviesTable.Price * 0.08; Replace with call to .Business project
            //Calc cl = new Calc();

            //ViewBag.Tax = cl.GetTax(moviesTable.Price);
            //ViewBag.Total = cl.GetTotal(moviesTable.Price);
            //return View("~/Views/MoviesTables/Cart.cshtml", moviesTable);
        }
Ejemplo n.º 2
0
 public static Movie FromMovieVMToMovie(MoviesVM movie)
 {
     return(new Movie()
     {
         Duration = movie.Duration,
         MovieGenre = movie.MovieGenre,
         MovieRating = movie.MovieRating,
         Title = movie.Title
     });
 }
Ejemplo n.º 3
0
        //converting function from entitiy model to the view model objects.
        private List <MoviesVM> ConvertMoviesToVM(List <Movies> movies)
        {
            List <MoviesVM> moviesVm = new List <MoviesVM>();

            foreach (var item in movies)
            {
                MoviesVM vm = new MoviesVM
                {
                    MovieID      = item.MovieID,
                    Picture      = item.Picture,
                    MovieName    = item.MovieName,
                    CategoryName = item.Categorys.CategoryName,
                    MovieTrailer = item.MovieTrailer,
                    Level        = (int)(item.Level)
                };
                moviesVm.Add(vm);
            }
            return(moviesVm);
        }
Ejemplo n.º 4
0
        //converting function from entitiy model to the view model objects.
        private List <MoviesVM> ConvertMoviesToVM(List <Movies> movies)
        {
            List <MoviesVM> moviesVm = new List <MoviesVM>();

            foreach (var item in movies)
            {
                MoviesVM vm = new MoviesVM
                {
                    MovieID      = item.MovieID,
                    Picture      = item.Picture,
                    MovieName    = item.MovieName,
                    CategoryName = item.Categorys.CategoryName,
                    Ranking      = item.Ranking,
                    MovieTrailer = item.MovieTrailer,
                    Level        = (Double)item.Prices.Price,
                };
                moviesVm.Add(vm);
            }
            return(moviesVm);
        }
Ejemplo n.º 5
0
        public ActionResult AddMovie(MoviesVM model)
        {
            MoviesDTO dto = new MoviesDTO();



            using (Db db = new Db())
            {
                ViewBag.Category = new SelectList(db.Category, "Id", "Name");

                dto.Name = model.Name;
                if (db.Movie.Any(x => x.Name == model.Name))
                {
                    ModelState.AddModelError("", "The title already taken");
                    return(View(model));
                }
                string yr = model.Year.ToString();
                if (string.IsNullOrWhiteSpace(model.Name) || string.IsNullOrWhiteSpace(model.Language) || string.IsNullOrWhiteSpace(model.Category) || string.IsNullOrWhiteSpace(model.Genre) || string.IsNullOrWhiteSpace(yr))
                {
                    ModelState.AddModelError("", "All fields required");
                    return(View(model));
                }
                dto.Category = model.Category;
                dto.Genre    = model.Genre;
                dto.Year     = model.Year;
                dto.Language = model.Language;
                db.Movie.Add(dto);
                db.SaveChanges();



                //temp data
                TempData["SM"] = "Movie Added!";
            }

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 6
0
        public void CreateNewMovie(MoviesVM movieVm)
        {
            var movie = Mappers.FromMovieVMToMovie(movieVm);

            _movieRepo.Create(movie);
        }