public static bool GetCustomer(string CustomerName) { string strConnectionString = DalUtils.GetConnectionSring(); List <Customer> listCustomer = StorageHelper.GetCustomerList(); bool UserExist = listCustomer.Exists(item => item.Name == CustomerName); return(UserExist); }
//add if movie not rented public static void InsertIntoRentalTable(int MovieId, int CustomerId) { string strConnectionString = DalUtils.GetConnectionSring(); DataClasses1DataContext nw = new DataClasses1DataContext(strConnectionString); Rental newRental = new Rental(); newRental.MovieId = MovieId; newRental.CustomerId = CustomerId; nw.Rentals.InsertOnSubmit(newRental); nw.SubmitChanges(); }
public static void AddNewCustomerIntoTable(string CustomerName, string CustomerSelect, int CustomerAge) { //int rowsAffected; string strConnectionString = DalUtils.GetConnectionSring(); DataClasses1DataContext nw = new DataClasses1DataContext(strConnectionString); Customer newCustomer = new Customer { Name = CustomerName, Subscription = CustomerSelect, Age = CustomerAge }; nw.Customers.InsertOnSubmit(newCustomer); nw.SubmitChanges(); }
public static void AddNewMovieIntoTable(string MovieName, string MovieCategory) { string strConnectionString = DalUtils.GetConnectionSring(); List <Movy> movyList = new List <Movy>(); DataClasses1DataContext nw = new DataClasses1DataContext(strConnectionString); Movy NewMovie = new Movy { Name = MovieName, Category = MovieCategory }; nw.Movies.InsertOnSubmit(NewMovie); nw.SubmitChanges(); }
public static List <Movy> GetMovieList() { string strConnectionString = DalUtils.GetConnectionSring(); List <Movy> listMovie = new List <Movy>(); DataClasses1DataContext nw = new DataClasses1DataContext(strConnectionString); var resultQuery = from cust in nw.Movies select cust; foreach (var item in resultQuery) { listMovie.Add(new Movy { Id = item.Id, Name = item.Name, Category = item.Category }); } return(listMovie); }
//movieId Exist in RentalTable public static bool MovieIdExistInRental(int movieID) { string strConnectionString = DalUtils.GetConnectionSring(); List <Rental> listRent = new List <Rental>(); DataClasses1DataContext nw = new DataClasses1DataContext(strConnectionString); var resultQuery = from rent in nw.Rentals select rent; foreach (var item in resultQuery) { listRent.Add(new Rental { MovieId = item.MovieId, CustomerId = item.CustomerId }); } bool IdMovieExistInRental = listRent.Exists(item => item.MovieId == movieID); return(IdMovieExistInRental); }
public static List <Customer> GetCustomerList() { string strConnectionString = DalUtils.GetConnectionSring(); List <Customer> listCustomer = new List <Customer>(); DataClasses1DataContext nw = new DataClasses1DataContext(strConnectionString); var resultQuery = from cust in nw.Customers select cust; foreach (var item in resultQuery) { listCustomer.Add(new Customer { Id = item.Id, Name = item.Name, Subscription = item.Subscription, Age = item.Age }); } return(listCustomer); }