Example #1
0
        public void Register(string Firstname, string Lastname, int age)
        {
            Reg.FirstName = Firstname;
            Reg.LastName  = Lastname;
            Reg.Age       = age;

            context.Registers.Add(Reg);
            context.SaveChanges();
        }
Example #2
0
 public void CustDelte(int CustID)
 {
     using (VideoEntities3 context = new VideoEntities3())
     {
         Customer obj = context.Customers.First(x => x.CustID == CustID); //this delete the cust id if it matches the varable
         context.Customers.Remove(obj);
         context.SaveChanges();                                           //this saves the changes
     }
 }
Example #3
0
 public void VideoDelte(int movieID)
 {
     using (VideoEntities3 context = new VideoEntities3())
     {
         Movy obj = context.Movies.First(x => x.MovieID == movieID); //this delte the row where movie id matches with variable
         context.Movies.Remove(obj);
         context.SaveChanges();                                      //this saves the changes
     }
 }
Example #4
0
        public void Cust_add(string Firstname, string lastname, string phone, string address)
        {
            cust.FirstName = Firstname;
            cust.LastName  = lastname;
            cust.Phone     = phone;//this puts the value of variable to databse
            cust.Address   = address;

            context.Customers.Add(cust);
            context.SaveChanges();//this save the changes to databse
        }
Example #5
0
        public void VideoAdd(string Title, string Rateing, string copies, string Genre, string Plot, string Year)
        {
            vid.Title  = Title;
            vid.Rating = Rateing;//it adds the value of variable to the the database
            vid.Genre  = Genre;
            vid.Plot   = Plot;
            vid.Copies = copies;
            vid.Year   = Year;
            int rentalcost = Convert.ToInt32(Year);

            vid.Rental_Cost = rentalcost <= 2014 ? 2 : 5;

            context.Movies.Add(vid);
            context.SaveChanges();//this saves the changes
        }
Example #6
0
        public void CustUpdate(int CustID, string Firstname, string lastname, string phone, string address)
        {
            using (var db = new VideoEntities3())
            {
                var result = db.Customers.SingleOrDefault(b => b.CustID == CustID);//this updates the whole row where cust id is same as varable
                if (result != null)
                {
                    result.FirstName = Firstname;
                    result.LastName  = lastname;
                    result.Phone     = phone;
                    result.Address   = address;


                    db.SaveChanges();//this saves the changes
                }
            }
        }
Example #7
0
        public void VideoUpdate(int movieID, string Title, string Rateing, string copies, string Genre, string Plot, string Year)
        {
            using (var db = new VideoEntities3())
            {
                var result = db.Movies.SingleOrDefault(b => b.MovieID == movieID);//this updates the roe where movie id matches with variable
                if (result != null)
                {
                    result.Title  = Title;
                    result.Rating = Rateing;
                    result.Genre  = Genre;
                    result.Plot   = Plot;
                    result.Copies = copies;
                    result.Year   = Year;

                    db.SaveChanges();//this saves the changes
                }
            }
        }