static public int GetmovieId(string movieName) { DataClasses3DataContext nw = new DataClasses3DataContext(DalUtils.GetConnectionString()); var getMovieId = nw.Movies.Where(x => x.Name == movieName).FirstOrDefault(); return(getMovieId.Id); }
static public int GetcustomerId(string custName) { DataClasses3DataContext nw = new DataClasses3DataContext(DalUtils.GetConnectionString()); var getCustId = nw.Customers.Where(x => x.Name == custName).FirstOrDefault(); return(getCustId.Id); }
public static void InsertNewCustomer(string strCustName, int intAge, string strSubscription) { DataClasses3DataContext nw = new DataClasses3DataContext(DalUtils.GetConnectionString()); Customer cust = new Customer(); cust.Name = strCustName; cust.Age = intAge; cust.Subscription = strSubscription; nw.Customers.InsertOnSubmit(cust); nw.SubmitChanges(); }
public static void InsertNewMovie(string strMovieName, string strCategoryName) { string strConnectionString = DalUtils.GetConnectionString(); DataClasses3DataContext nw = new DataClasses3DataContext(DalUtils.GetConnectionString()); Movies movie = new Movies(); movie.Name = strMovieName; movie.Category = strCategoryName; nw.Movies.InsertOnSubmit(movie); nw.SubmitChanges(); }
public static void InsertNewRental(string strCustName, string strMovieName)//כותב לטבלה את הנתונים ומחזיר כמה שורות הושפעו { DataClasses3DataContext nw = new DataClasses3DataContext(DalUtils.GetConnectionString()); int getCustId = GetcustomerId(strCustName); int getMovieId = GetmovieId(strMovieName); Rental rental = new Rental(); rental.CustID = getCustId; rental.MovieID = getMovieId; nw.Rentals.InsertOnSubmit(rental); nw.SubmitChanges(); }
static public void DeleteRentedMovie(string Name, string Movie) { int getCustId = GetcustomerId(Name); int getMovieId = GetmovieId(Movie); DataClasses3DataContext nw = new DataClasses3DataContext(DalUtils.GetConnectionString()); var listToBeDeleted = nw.Rentals.Where(x => x.CustID == getCustId && x.MovieID == getMovieId); foreach (var item in listToBeDeleted) { nw.Rentals.DeleteOnSubmit(item); } nw.SubmitChanges(); }
public static List <Movies> GetMoviesList() { List <Movies> list = new List <Movies>(); DataClasses3DataContext nw = new DataClasses3DataContext(DalUtils.GetConnectionString()); var resultQuery = from movie in nw.Movies select movie; foreach (var item in resultQuery) { list.Add(new Movies { Id = item.Id, Name = item.Name, Category = item.Category }); } return(list); }
public static List <Rental> GetRentalList() { List <Rental> list = new List <Rental>(); DataClasses3DataContext nw = new DataClasses3DataContext(DalUtils.GetConnectionString()); var resultQuery = from rent in nw.Rentals select rent; foreach (var item in resultQuery) { list.Add(new Rental { Id = item.Id, CustID = item.CustID, MovieID = item.MovieID }); } return(list); }
public static List <Customer> GetCustomersList() { List <Customer> list = new List <Customer>(); DataClasses3DataContext nw = new DataClasses3DataContext(DalUtils.GetConnectionString()); var resultQuery = from cust in nw.Customers select cust; foreach (var item in resultQuery) { list.Add(new Customer { Id = item.Id, Name = item.Name, Age = item.Age, Subscription = item.Subscription }); } return(list); }