Exemple #1
0
        public void OrderToys(int CategoryId, int CustomerId)
        {
            string ToyName;

            using (var toyapp = new ToyApplicationDbContext())
            {
                var toys = toyapp.Toys.Where(t => t.CategoryId == CustomerId).ToList();
                foreach (var i in toys)
                {
                    Console.WriteLine("ToyId:" + i.ToyId + " ToyName" + i.ToyName + "Price" + i.Price);
                }
                Console.WriteLine("Enter Toy Name");
                ToyName = Console.ReadLine();
                int ToyId = toyapp.Toys.SingleOrDefault <Toys>(t => t.ToyName == ToyName).ToyId;
                Console.WriteLine("enter Quantity");
                int quantity = Int32.Parse(Console.ReadLine());
                Console.WriteLine("Enter Address");
                string address = Console.ReadLine();

                var order = new Orders
                {
                    CustomerId = CustomerId,
                    ToyId      = ToyId,
                    Address    = address,
                    Quantity   = quantity
                };
                toyapp.Orders.Add(order);
                toyapp.SaveChanges();
                Console.WriteLine("Order placed success..");
            }
        }
Exemple #2
0
        public void CustomerRegister()
        {
            int CustomerId = 0;

            using (var toyapp = new ToyApplicationDbContext())
            {
                string Name, Email, Mobile, Password;

                Console.WriteLine("Enter Name");
                Name = Console.ReadLine();
                Console.WriteLine("Enter Contact Number");
                Mobile = Console.ReadLine();
                Console.WriteLine("Enter Email");
                Email = Console.ReadLine();
                Console.WriteLine("Enter Password");
                Password = Console.ReadLine();

                var customer = new Customers
                {
                    CustomerName = Name,
                    Mobile       = Mobile,
                    Email        = Email,
                    Password     = Password
                };
                toyapp.Customers.Add(customer);

                toyapp.SaveChanges();
                CustomerId = customer.CustomerId;

                Console.WriteLine("Successfully Added");
                ViewSchemes(CustomerId);
            }
        }
Exemple #3
0
        public void AddToy()
        {
            string ToyName, Description, CategoryName, PlantName;
            int    Price;

            using (var toyapp = new ToyApplicationDbContext())
            {
                Console.WriteLine("Enter Toy Name");
                ToyName = Console.ReadLine();
                Console.WriteLine("Enter Toy Description");
                Description = Console.ReadLine();
                Console.WriteLine("Enter Price");
                Price = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Enter Category Name");
                CategoryName = Console.ReadLine();

                int CategoryId = toyapp.ToyCategory.SingleOrDefault <ToyCategory>(t => t.ToyCategoryName == CategoryName).ToyCategoryId;
                Console.WriteLine("Enter Plant Name");
                PlantName = Console.ReadLine();
                int PlantId = toyapp.Plants.SingleOrDefault <Plants>(t => t.PlantName == PlantName).PlantId;

                var toy = new Toys
                {
                    ToyName     = ToyName,
                    Description = Description,
                    Price       = Price,
                    CategoryId  = CategoryId,
                    PlantId     = PlantId
                };
                toyapp.Toys.Add(toy);
                toyapp.SaveChanges();
                Console.WriteLine(" Toy  Successfully Added");
            }
        }
Exemple #4
0
 public void AddToyCategory()
 {
     using (var toyapp = new ToyApplicationDbContext())
     {
         string CategoryName;
         Console.WriteLine("Enter CategoryName");
         CategoryName = Console.ReadLine();
         var toycategory = new ToyCategory
         {
             ToyCategoryName = CategoryName,
         };
         toyapp.ToyCategory.Add(toycategory);
         toyapp.SaveChanges();
         Console.WriteLine(" Toy Category Successfully Added");
     }
 }
Exemple #5
0
        public void AddSchemes()
        {
            using (var toyapp = new ToyApplicationDbContext())
            {
                string schemeName, Description;
                Console.WriteLine("Enter schemeName");
                schemeName = Console.ReadLine();
                Console.WriteLine("Enter Description");
                Description = Console.ReadLine();

                var scheme = new Schemes
                {
                    SchemeName  = schemeName,
                    Description = Description
                };
                toyapp.Schemes.Add(scheme);

                toyapp.SaveChanges();

                Console.WriteLine(" Scheme Successfully Added");
            }
        }
Exemple #6
0
        public void AddPlant()
        {
            using (var toyapp = new ToyApplicationDbContext())
            {
                string plantName, plantAddress;
                Console.WriteLine("Enter plantName");
                plantName = Console.ReadLine();
                Console.WriteLine("Enter plantAddress");
                plantAddress = Console.ReadLine();

                var plant = new Plants
                {
                    PlantName = plantName,
                    Address   = plantAddress
                };
                toyapp.Plants.Add(plant);

                toyapp.SaveChanges();

                Console.WriteLine(" Plant Successfully Added");
            }
        }