Ejemplo n.º 1
0
        public void NewUser()
        {
            ToysCustomerContex c1 = new ToysCustomerContex();

            Console.WriteLine("Enter Your Name :-");
            string Name = Console.ReadLine();

            Console.WriteLine("Enter Contect Number");
            double number = Convert.ToDouble(Console.ReadLine());

            Console.WriteLine("Enter street Name :-");
            string street = Console.ReadLine();

            Console.WriteLine("Enter City");
            string city = Console.ReadLine();

            Console.WriteLine("Enter state ");
            string state = Console.ReadLine();

            Console.WriteLine("Enter Zip");
            double zip = Convert.ToDouble(Console.ReadLine());


            List <Customer> cus = new List <Customer>()
            {
                new Customer {
                    CustomerName = Name, ContectNumber = number
                }
            };

            foreach (var item in cus)
            {
                c1.Customers.Add(item);
                c1.SaveChanges();
            }


            var            id        = c1.Customers.Single(s => s.CustomerName == Name);
            List <Address> addresses = new List <Address>()
            {
                new Address()
                {
                    street = street, State = state, City = city, Zip = zip, CustomerId = id.CustomerId
                }
            };

            foreach (var item in addresses)
            {
                c1.Addresses.Add(item);
                c1.SaveChanges();
            }
            Console.WriteLine($"Your Customer Id Number Is : {id.CustomerId}");

            Console.WriteLine("SuccessFully Register");
        }
Ejemplo n.º 2
0
        public void RemoveBkkoing()
        {
            try
            {
                ToysCustomerContex c1 = new ToysCustomerContex();
                Console.WriteLine("Enter your Customer Name ");
                string name = Console.ReadLine();
                Console.WriteLine("Enter Toy you Want To Delete");
                string toy = Console.ReadLine();

                var custid = c1.ToysPeople.Include(s => s.Toys).Include(s => s.Customer).Where
                                 (s => s.Customer.CustomerName == name).Where(s => s.Toys.ToyName == toy);

                foreach (var item in custid)
                {
                    c1.ToysPeople.Remove(item);
                }
                c1.SaveChanges();
                Console.WriteLine("Successfully remove the Toy");
            }
            catch (Exception e)
            {
                Console.WriteLine("Check Your Details you are Enterd");
            }
        }
Ejemplo n.º 3
0
        public void OrderToy()
        {
            try
            {
                Console.WriteLine("Enter customer Name :-");
                string custname = Console.ReadLine();
                Console.WriteLine("Enter toy name");
                string             toyname = Console.ReadLine();
                ToysCustomerContex c1      = new ToysCustomerContex();
                var customerid             = c1.Customers.Single(s => s.CustomerName == custname);
                var toyid = c1.Toys.Single(s => s.ToyName == toyname);
                List <ToysPerson> bookingdata = new List <ToysPerson>()
                {
                    new ToysPerson()
                    {
                        CustomerId = customerid.CustomerId, ToyId = toyid.ToyId
                    }
                };
                foreach (var item in bookingdata)
                {
                    c1.ToysPeople.Add(item);
                    c1.SaveChanges();
                }

                Console.WriteLine("SuccessFully Booked your Toy");
            }
            catch (Exception e)
            {
                Console.WriteLine("You All Ready Booked this item");
            }
        }
Ejemplo n.º 4
0
        public void Deletedata()
        {
            try
            {
                ToysCustomerContex c1 = new ToysCustomerContex();

                Console.WriteLine("Enter Customer Id You Want to Delete");
                int id   = Convert.ToInt32(Console.ReadLine());
                var data = c1.Customers.Single(p => p.CustomerId == id);
                c1.Remove(data);
                c1.SaveChanges();
                Console.WriteLine("Deleted data Successfully");
            }
            catch (Exception e)
            {
                Console.WriteLine("Sorry Customer Id Is Not Available");
            }
        }
Ejemplo n.º 5
0
        public void UpdateCustomer()
        {
            try
            {
                ToysCustomerContex c1 = new ToysCustomerContex();
                Console.WriteLine("Enter You Customer Id Number ");
                int id = Convert.ToInt32(Console.ReadLine());

                var data = c1.Customers.Single(s => s.CustomerId == id);
                Console.WriteLine("Enter New Name");
                data.CustomerName = Console.ReadLine();
                Console.WriteLine("Enter Contect Number");
                data.ContectNumber = Convert.ToDouble(Console.ReadLine());
                c1.SaveChanges();
            }
            catch (Exception e)
            {
                Console.WriteLine("Sorry Id Is Not Vailable");
            }
        }