public async Task <IActionResult> Edit(int id, [Bind("LenovoId,Name,Model,Year")] Lenovo lenovo)
        {
            if (id != lenovo.LenovoId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(lenovo);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LenovoExists(lenovo.LenovoId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(lenovo));
        }
Example #2
0
        static void Main(string[] args)
        {
            ILaptop laptop;

            laptop = new Lenovo();
            laptop.menyala();
            Console.WriteLine();
            laptop = new Asus();
            laptop.menyala();
            Console.ReadKey();
        }
        public async Task <IActionResult> Create([Bind("LenovoId,Name,Model,Year")] Lenovo lenovo)
        {
            if (ModelState.IsValid)
            {
                _context.Add(lenovo);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(lenovo));
        }
Example #4
0
        //简单工厂最核心的地方
        public static NoteBook GetNoteBook(string note)
        {
            NoteBook nb = null;

            switch (note)
            {
            case "Acer": nb = new Acer(); break;

            case "IBM": nb = new IBM(); break;

            case "DELL": nb = new DELL(); break;

            case "Lenovo": nb = new Lenovo(); break;
            }
            return(nb);
        }
        static void Main(string[] args)
        {
            IComputer      lenovocomputer = new Lenovo();
            ComputerClient lenovocliente  = new ComputerClient(lenovocomputer);

            Console.WriteLine("********* Lenovo **********");
            Console.WriteLine(lenovocliente.GetSmartPhoneModelDetails());
            Console.WriteLine(lenovocliente.GetNormalPhoneModelDetails());

            IComputer      dellcomputer = new Dell();
            ComputerClient dellcliente  = new ComputerClient(dellcomputer);

            Console.WriteLine("******* Dell **********");
            Console.WriteLine(dellcliente.GetSmartPhoneModelDetails());
            Console.WriteLine(dellcliente.GetNormalPhoneModelDetails());

            Console.ReadKey();
        }
Example #6
0
        public static NoteBook GetNoteBook(string brand)
        {
            NoteBook nb = null;

            switch (brand)
            {
            case "Lenove": nb = new Lenovo();
                break;

            case "Acer": nb = new Acer();
                break;

            case "Dell": nb = new Dell();
                break;
            }


            return(nb);
        }
Example #7
0
        /// <summary>
        /// 简单工厂的核心 根据用户的输入创建对象赋值给父类
        /// </summary>
        /// <param name="brand"></param>
        /// <returns></returns>
        public static NoteBook GetNoteBook(string brand)
        {
            NoteBook nb = null;

            switch (brand)
            {
            case "Lenovo": nb = new Lenovo();   //创建子类的对象,赋值给父类
                break;

            case "IBM": nb = new IBM();
                break;

            case "Acer": nb = new Acer();
                break;

            case "Dell": nb = new Dell();
                break;
            }
            return(nb);
        }
Example #8
0
        static void Main(string[] args)
        {
            int pilih;

            do
            {
                Console.WriteLine("\n======== Toko Laptop & Komputer Awan ========\n");
                Console.WriteLine("Barang apa yang ingin anda beli : ");
                Console.WriteLine("1. Laptop ");
                Console.WriteLine("2. Komputer ");
                Console.WriteLine("3. Keluar ");
                Console.WriteLine("Masukan Pilihan Anda [1/2]  = ");
                pilih = Convert.ToInt32(Console.ReadLine());

                if (pilih == 1)
                {
                    Console.WriteLine("\n======== Laptop Toko Awan ========\n");
                    Console.WriteLine("Laptop apa yang ingin ingin anda beli : ");
                    Console.WriteLine("1. Acer ");
                    Console.WriteLine("2. Asus");
                    Console.WriteLine("3. Lenovo \n");
                    Console.WriteLine("Masukan Pilihan Anda [1-3]  = ");
                    int pilihlaptop = Convert.ToInt32(Console.ReadLine());

                    if (pilihlaptop == 1)
                    {
                        // Laptop Acer
                        Acer myAcer = new Acer();
                        myAcer.BeliLaptop();
                        myAcer.beliL();
                    }

                    else if (pilihlaptop == 2)
                    {
                        // Laptop Asus
                        Asus myAsus = new Asus();
                        myAsus.BeliLaptop();
                        myAsus.beliL();
                    }

                    else if (pilihlaptop == 3)
                    {
                        // Laptop Lenovo
                        Lenovo myLenovo = new Lenovo();
                        myLenovo.BeliLaptop();
                        myLenovo.beliL();
                    }

                    else
                    {
                        Console.WriteLine("Maaf Pilihan Tidak Tersedia");
                    }
                }

                else if (pilih == 2)
                {
                    Console.WriteLine("\n======== Komputer Toko Awan ========\n");
                    Console.WriteLine("Komputer apa yang ingin ingin anda beli : ");
                    Console.WriteLine("1. Komputer Biasa ");
                    Console.WriteLine("2. Komputer Gaming");
                    Console.WriteLine("3. Komputer VideoEditing \n");
                    Console.WriteLine("Masukan Pilihan Anda [1-3]  = ");
                    int pilihkomputer = Convert.ToInt32(Console.ReadLine());

                    if (pilihkomputer == 1)
                    {
                        Biasa myBiasa = new Biasa();
                        myBiasa.BeliKomputer();
                    }

                    else if (pilihkomputer == 2)
                    {
                        Gaming myGaming = new Gaming();
                        myGaming.BeliKomputer();
                    }

                    else if (pilihkomputer == 3)
                    {
                        VideoEditing myVideoEditing = new VideoEditing();
                        myVideoEditing.BeliKomputer();
                    }

                    else
                    {
                        Console.WriteLine("Maaf Pilihan Tidak Tersedia");
                    }
                }
            }while(pilih != 3);
        }