示例#1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Ad,Aciklama,Kilo")] Bebek Bebek)
        {
            if (id != Bebek.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(Bebek);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BebekExists(Bebek.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(Bebek));
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("Id,Ad,Aciklama,Kilo,Dosyalar")] Bebek Bebek)
        {
            if (ModelState.IsValid)
            {
                var dosyaYolu = Path.Combine(_hostEnvironment.WebRootPath, "resimler");
                if (!Directory.Exists(dosyaYolu))
                {
                    Directory.CreateDirectory(dosyaYolu);
                }

                foreach (var item in Bebek.Dosyalar)
                {
                    // IFormFile   -->  FileStream   :upload
                    using (var dosyaAkisi = new FileStream(Path.Combine(dosyaYolu, item.FileName), FileMode.Create))
                    {
                        await item.CopyToAsync(dosyaAkisi);
                    }

                    Bebek.Resimler.Add(new Resim {
                        DosyaAdi = item.FileName
                    });
                }

                _context.Add(Bebek);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(Bebek));
        }
示例#3
0
        public static void Implementasi()
        {
            Pecel pecel;
            bool  lagiKolesterol = false;

            if (lagiKolesterol == false)
            {
                pecel = new Bebek();
            }
            else
            {
                pecel = new Ayam();
            }
        }
示例#4
0
        public static void Main(string[] args)
        {
            //Your code goes here
            Console.WriteLine("Nama\t\t: M.Habibi Amin");
            Console.WriteLine("NIM\t\t: 19.11.2769");
            Console.WriteLine("Kelas\t\t: 19 IF 03");


            Console.WriteLine();

            Console.WriteLine("==== OS ====");

            Console.WriteLine();

            ACOperatingSystem os;

            os = new MacOS();
            os.pembuat();
            os.kernel();
            os.jenis();

            Console.WriteLine();

            os = new Windows();
            os.pembuat();
            os.kernel();
            os.jenis();


            Console.WriteLine();

            Console.WriteLine("==== HEWAN ====");

            Console.WriteLine();

            IHewan hewan;

            hewan = new Bebek();
            hewan.info();
            hewan.suara();
            hewan.jenis();

            Console.WriteLine();

            hewan = new Anjing();
            hewan.info();
            hewan.suara();
            hewan.jenis();
        }
        public Pecel BikinPecel(string TipePecel) // disini proses pembuatan object pecel sesuai pilihan terjadi
        {
            Pecel pecel = null;

            if (TipePecel == "ayam")
            {
                pecel = new Ayam();
            }
            else if (TipePecel == "bebek")
            {
                pecel = new Bebek();
            }

            return(pecel);
        }