Beispiel #1
0
        public ActionResult Save(Details_ViewModel _customer)
        {
            if (ModelState.IsValid)
            {
                if (_customer.Customer.Id == 0)
                {
                    this._context.Customers.Add(_customer.Customer);
                }
                else
                {
                    var _customerInDb = this._context.Customers
                                        .SingleOrDefault(c => c.Id == _customer.Customer.Id);

                    if (_customerInDb != null)
                    {
                        _customerInDb.Name                     = _customer.Customer.Name;
                        _customerInDb.BirthDate                = _customer.Customer.BirthDate;
                        _customerInDb.MembershipTypeId         = _customer.Customer.MembershipTypeId;
                        _customerInDb.IsSubscribedToNewsLetter = _customer.Customer.IsSubscribedToNewsLetter;
                    }
                }

                this._context.SaveChanges();
            }
            else
            {
                return(View("Form_Customer", this.NewRecord()));
            }

            return(RedirectToAction("Index", "Customer"));
        }
Beispiel #2
0
        public ActionResult Save(Details_ViewModel _movie)
        {
            if (ModelState.IsValid)
            {
                if (_movie.Movie.Id == 0)
                {
                    this._context.Movies.Add(_movie.Movie);
                }
                else
                {
                    var _movieInDb = this._context.Movies
                                     .SingleOrDefault(c => c.Id == _movie.Movie.Id);

                    if (_movieInDb != null)
                    {
                        _movieInDb.Name          = _movie.Movie.Name;
                        _movieInDb.ReleaseDate   = _movie.Movie.ReleaseDate;
                        _movieInDb.GenreId       = _movie.Movie.GenreId;
                        _movieInDb.NumberInStock = _movie.Movie.NumberInStock;
                    }
                }

                this._context.SaveChanges();
            }
            else
            {
                return(View("Form_Movie", this.NewRecord()));
            }

            return(RedirectToAction("Index", "Movie"));
        }
Beispiel #3
0
        public ViewResult Details(int Id)
        {
            this._details           = new Details_ViewModel();
            this._details.Customers = this._context.Customers
                                      .Include(c => c.MembershipType)
                                      .Where(c => c.Id == Id);

            foreach (var getCustomerName in this._details.Customers)
            {
                ViewBag.Title = getCustomerName.Name;
            }

            return(View(this._details));
        }
Beispiel #4
0
        public ViewResult Details(int Id)
        {
            this._details        = new Details_ViewModel();
            this._details.Movies = this._context.Movies
                                   .Include(m => m.Genre)
                                   .Where(m => m.Id == Id);

            foreach (var getMovieName in this._details.Movies)
            {
                ViewBag.Title = getMovieName.Name;
            }

            return(View(this._details));
        }