Exemplo n.º 1
0
 /// <summary>
 /// adds car-inventoryitem to the database
 /// </summary>
 /// <param name="car"></param>
 public void AddCar(Car car)
 {
     InventoryItem item = car;
     db.InventoryItems.Add(item);
     db.SaveChanges();
 }
Exemplo n.º 2
0
        /// <summary>
        /// calls pawnshop add method and adds inventoryitem
        /// </summary>
        private static void AddItem()
        {
            Console.Clear();
            Console.WriteLine("press 1 to add item,press 2 to add car, press 3 to add watch");
            int select = 0;
            int.TryParse(Console.ReadLine(), out select);
            switch(select)
            {
                case 1://adds regular InventoryItem
                    Console.Clear();
                    Console.WriteLine("Add Name");
                    string name=Console.ReadLine();
                    Console.WriteLine("Add Description");
                    string description=Console.ReadLine();
                    Console.WriteLine("Add Price");
                    double price=double.Parse(Console.ReadLine());
                    InventoryItem item=new InventoryItem(name,description,price);
                    ps.AddInventoryItem(item);
                    break;
                case 2://adds Car InventoryItem
                    Console.Clear();
                    Console.WriteLine("Add Name");
                    string cName=Console.ReadLine();
                    Console.WriteLine("Add Type");
                    string type = Console.ReadLine();
                    Console.WriteLine("Add Age");
                    int age = int.Parse(Console.ReadLine());
                    Console.WriteLine("Add Manufacturer");
                    string manufacturer = Console.ReadLine();

                    Console.WriteLine("Add Description");
                    string cDescription=Console.ReadLine();
                    Console.WriteLine("Add Price");
                    double cPrice=double.Parse(Console.ReadLine());
                    Console.WriteLine("Add condition(0 for new, 1 to used, 2 for bad)");
                    int condition = int.Parse(Console.ReadLine());
                    Car Citem=new Car(cName,cDescription,cPrice,type,age,manufacturer,(Car.Condition)condition);
                    ps.AddCar(Citem);
                    break;
                case 3://adds Watch InventoryItem
                    Console.Clear();
                    Console.WriteLine("Add Name");
                    string wName=Console.ReadLine();
                    Console.WriteLine("Add Description");
                    string wDescription=Console.ReadLine();
                    Console.WriteLine("Add Price");
                    double wPrice=double.Parse(Console.ReadLine());
                    Console.WriteLine("Add Material(0 for gold,1 for silver 2 for rubber and 3 for other");
                    int material = int.Parse(Console.ReadLine());
                    Watch Witem=new Watch(wName,wDescription,wPrice,(Watch.Material)material);
                    ps.AddWatch(Witem);
                    break;
                default:
                    Console.WriteLine("Wrong input");
                    break;
            }
        }