public ActionResult Create([Bind(Include = "CustomerID,FirstName,LastName,Phone")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                db.Customers.Add(customer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(customer));
        }
Beispiel #2
0
        public ActionResult Create([Bind(Include = "MovieID,Title,Director,Genre")] Movy movy)
        {
            if (ModelState.IsValid)
            {
                db.Movies.Add(movy);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(movy));
        }
        public ActionResult Create([Bind(Include = "RentalID,CustomerID,MovieID,RentalDate")] Rental rental)
        {
            if (ModelState.IsValid)
            {
                db.Rentals.Add(rental);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "FirstName", rental.CustomerID);
            ViewBag.MovieID    = new SelectList(db.Movies, "MovieID", "Title", rental.MovieID);
            return(View(rental));
        }
Beispiel #4
0
 public void InsertCustomers_DAL(Customer obj_Customers_insert)
 {
     using (MovieRentalDBEntities db = new MovieRentalDBEntities())
     {
         //adding object to movies table
         db.Customers.Add(obj_Customers_insert);
         db.SaveChanges();
     }
 }
 // calling the object from business.Movies_BAL
 public void InsertMovies_DAL(Movy obj_movie_insert)
 {
     using (MovieRentalDBEntities db = new MovieRentalDBEntities())
     {
         //adding object to movies table
         db.Movies.Add(obj_movie_insert);
         db.SaveChanges();
     }
 }
Beispiel #6
0
 //Inserting data to return movie table
 public static void InsertReturnedMovie(MovieReturned Obj_Returned_Movie_Insert)
 {
     try
     {
         using (MovieRentalDBEntities db = new MovieRentalDBEntities())
         {
             db.MovieReturneds.Add(Obj_Returned_Movie_Insert);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #7
0
 public static void DeletCustomer(string Obj_Cust_Delete)
 {
     try
     {
         using (MovieRentalDBEntities db = new MovieRentalDBEntities())
         {
             //Lembda expression for deleting customer
             Customer c = db.Customers.SingleOrDefault(x => x.CustomerID.ToString().Trim() == Obj_Cust_Delete.Trim());
             if (c != null)
             {
                 db.Customers.Remove(c);
                 db.SaveChanges();
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public static void DeleteMovie(string Obj_mov_Delete)
 {
     try
     {
         using (MovieRentalDBEntities db = new MovieRentalDBEntities())
         {
             //Lembda expression to delete movie
             Movy c = db.Movies.SingleOrDefault(x => x.MovieID.ToString().Trim() == Obj_mov_Delete.Trim());
             if (c != null)
             {
                 db.Movies.Remove(c);
                 db.SaveChanges();
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #9
0
        public static int UpdateCustomer(Customer Obj_Cust_Update)
        {
            try
            {
                using (MovieRentalDBEntities db = new MovieRentalDBEntities())
                {
                    //Lembda expression for updating customer

                    Customer c = db.Customers.SingleOrDefault(x => x.CustomerID == Obj_Cust_Update.CustomerID);
                    c.FirstName = Obj_Cust_Update.FirstName;
                    c.LastName  = Obj_Cust_Update.LastName;
                    c.Address   = Obj_Cust_Update.Address;
                    c.Phone     = Obj_Cust_Update.Phone;
                    db.SaveChanges();
                    return(Obj_Cust_Update.CustomerID);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static int UpdateMovie(Movy Obj_Movi_Update)
        {
            try
            {
                using (MovieRentalDBEntities db = new MovieRentalDBEntities())
                {
                    //Lembda expression to update movie

                    Movy c = db.Movies.SingleOrDefault(x => x.MovieID == Obj_Movi_Update.MovieID);
                    c.Title      = Obj_Movi_Update.Title;
                    c.Year       = Obj_Movi_Update.Year;
                    c.Gener      = Obj_Movi_Update.Gener;
                    c.RentPerDay = Obj_Movi_Update.RentPerDay;
                    db.SaveChanges();
                    return(Obj_Movi_Update.MovieID);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }