Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 public static Type GetCSharpType(string sqlType, bool nullable)
 {
     if (nullable)
     {
         return(typeof(Nullable <>).MakeGenericType(DalUtils.GetBaseCSharpType(sqlType)));
     }
     else
     {
         return(DalUtils.GetBaseCSharpType(sqlType));
     }
 }
Esempio n. 3
0
        //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();
        }
Esempio n. 4
0
        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();
        }
Esempio n. 5
0
        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();
        }
Esempio n. 6
0
        public async Task <OperationResult <DatabaseMeta> > GetDatabaseMeta(ContractOrderDictionary idx)
        {
            var procsResult = await GetProcedures(idx).ConfigureAwait(false);

            if (procsResult.Fail() || procsResult.Data.EmptyIfNull().Any(r => r.Fail()))
            {
                return(new OperationResult <DatabaseMeta>($"Errors on collect procedures data: [{ string.Join(",", (procsResult as IOperationResult).Yield().Union(procsResult.Data.EmptyIfNull()).Where(i => i.Fail()).Select(i => i.StatusMessage).ToArray()) }]"));
            }
            else
            {
                SqlConnectionStringBuilder conBuilder = new SqlConnectionStringBuilder(options.ConnectionString);
                return(new OperationResult <DatabaseMeta>(new DatabaseMeta()
                {
                    Name = DalUtils.StripUnderscorePrefix(conBuilder.InitialCatalog),
                    Procedures = procsResult.Data.Select(i => i.Data).ToArray()
                }));
            }
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        //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);
        }
Esempio n. 9
0
        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);
        }