Example #1
0
        public ActionResult Edit(PelangganViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var pelanggan = new Pelanggan
            {
                Kode   = model.Kode,
                Alamat = model.Alamat,
                Hp     = model.Hp,
                Nama   = model.Nama,
                NoKtp  = model.NoKtp
            };

            _db.Entry(pelanggan).State = EntityState.Modified;
            _db.SaveChanges();

            return(RedirectToAction("Index"));
        }
        public ActionResult Edit(BarangViewModel model)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.KodeTipeCuci = new SelectList(_db.TipeCucis, "Kode", "Tipe", model.KodeTipeCuci);

                return(View(model));
            }

            var barang = new Barang
            {
                Kode         = model.Kode,
                Harga        = model.Harga,
                Nama         = model.Nama,
                KodeTipeCuci = model.KodeTipeCuci
            };

            _db.Entry(barang).State = EntityState.Modified;

            _db.SaveChanges();

            return(RedirectToAction("Index"));
        }