public async Task <IActionResult> Edit(int id, [Bind("OppoId,imageName,OppoAciklama,Fiyat")] Oppo oppo) { if (id != oppo.OppoId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(oppo); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OppoExists(oppo.OppoId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(oppo)); }
static void Main(string[] args) { ISmartphone ismartphone; ismartphone = new INokia(); ismartphone.Merk(); Console.WriteLine(); ismartphone = new Oppo(); ismartphone.Merk(); Console.ReadKey(); }
static void Main(string[] args) { //AbtractionClass //Handphone handphone; //Console.WriteLine(); //handphone = new Samsung(); //handphone.Buatan(); //Console.WriteLine(); //handphone = new Vivo(); //handphone.Buatan(); //Console.WriteLine(); //handphone = new Xiaomi(); //handphone.Buatan(); //Interface IHandphone handphone; ILokasi lokasi; handphone = new Oppo(); handphone.Buatan(); lokasi = new Oppo(); lokasi.Kota(); Console.WriteLine(); handphone = new Vivo(); handphone.Buatan(); lokasi = new Vivo(); lokasi.Kota(); Console.WriteLine(); handphone = new Xiaomi(); handphone.Buatan(); lokasi = new Xiaomi(); lokasi.Kota(); Console.ReadKey(); }
public async Task <IActionResult> Create([Bind("OppoId,imageFile,OppoAciklama,Fiyat")] Oppo oppo) { if (ModelState.IsValid) { string wwRootPath = _hostEnvironment.WebRootPath; string fileName = Path.GetFileNameWithoutExtension(oppo.imageFile.FileName); string extention = Path.GetExtension(oppo.imageFile.FileName); oppo.imageName = fileName = fileName + DateTime.Now.ToString("yymmssfff") + extention; string path = Path.Combine(wwRootPath + "/image/Oppo/", fileName); using (var fileStream = new FileStream(path, FileMode.Create)) { await oppo.imageFile.CopyToAsync(fileStream); } _context.Add(oppo); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(oppo)); }