Ejemplo n.º 1
0
 public List <Customer> GetCustomersData_DAL()
 {
     using (MovieRentalDBEntities db = new MovieRentalDBEntities())
     {
         // To list the Customers using LINQ Queries
         var query = (from c in db.Customers select c).ToList();
         return(query);
     }
 }
Ejemplo n.º 2
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();
     }
 }
Ejemplo n.º 3
0
 // 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();
     }
 }
Ejemplo n.º 4
0
 public List <Movy> GetMoviesData_DAL()
 {
     using (MovieRentalDBEntities db = new MovieRentalDBEntities())
     {
         // To list the Movies using LINQ Queries
         // m is an object with fetching the data with Database Movies
         var query = (from m in db.Movies select m).ToList();
         return(query);
     }
 }
Ejemplo n.º 5
0
 public List <MovieReturned> GetMovieReturnedData_DAL()
 {
     using (MovieRentalDBEntities db = new MovieRentalDBEntities())
     {
         // To list the Movie Return using LINQ Queries
         // a is an object with fetching the data with Database of table MovieReturn
         var query = (from a in db.MovieReturneds select a).ToList();
         return(query);
     }
 }
Ejemplo n.º 6
0
 public List <MovieReturned> GetMovyReturnedDetails_DAL(string selectedValue)
 {
     using (MovieRentalDBEntities db = new MovieRentalDBEntities())
     {
         // To list the Movie Return using LINQ Queries
         // u is an object with fetching the data with Database of table MovieRent
         //selected value is the parameter for search query with RentID
         List <MovieReturned> Obj_Return_Detail = (from u in db.MovieReturneds where u.ReturnID.ToString() == selectedValue select u).ToList();
         return(Obj_Return_Detail);
     }
 }
Ejemplo n.º 7
0
        //To get the details from the drop down box to select the data
        public List <Customer> GetCustomerDetails_DAL(string selectedValue)
        {
            List <Customer> Obj_Customer_Detail = null;

            using (MovieRentalDBEntities db = new MovieRentalDBEntities())
            {
                // To list the Movie Return using LINQ Queries
                // u is an object with fetching the data with Database of table Customer
                //selected value is the parameter for search query with CustomerId
                Obj_Customer_Detail = (from u in db.Customers where u.CustomerID.ToString() == selectedValue select u).ToList();
                return(Obj_Customer_Detail);
            }
        }
Ejemplo n.º 8
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;
     }
 }
Ejemplo n.º 9
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;
     }
 }
Ejemplo n.º 10
0
 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;
     }
 }
Ejemplo n.º 11
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;
            }
        }
Ejemplo n.º 12
0
        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;
            }
        }