public BarangCreateEditViewModel GetBarangCreateViewModel() { var viewModel = new BarangCreateEditViewModel(); viewModel.KategoriLookup = context.Kategoris; viewModel.LokasiLookup = context.Lokasis; return(viewModel); }
public void EditBarang(BarangCreateEditViewModel model) { var barang = GetBarang(model.ID); barang.Nama = model.Nama; barang.HargaBeli = model.HargaBeli; barang.HargaJual = model.HargaJual; barang.KategoriID = model.KategoriID; barang.LokasiID = model.LokasiID; context.SaveChanges(); }
public ActionResult Edit(BarangCreateEditViewModel model) { try { barangProvider.EditBarang(model); return(RedirectToAction("Index")); } catch (Exception) { return(RedirectToAction("Edit")); } }
public ActionResult Create(BarangCreateEditViewModel model) { try { barangProvider.AddBarang(model); return(RedirectToAction("Index")); } catch (Exception ex) { throw ex; return(RedirectToAction("Create")); } }
public void AddBarang(BarangCreateEditViewModel model) { var barang = new Barang() { Nama = model.Nama, HargaBeli = model.HargaBeli, HargaJual = model.HargaJual, LokasiID = model.LokasiID, KategoriID = model.KategoriID }; context.Add(barang); context.SaveChanges(); }
public BarangCreateEditViewModel GetBarangEditViewModel(int id) { var barang = GetBarang(id); var viewModel = new BarangCreateEditViewModel() { ID = barang.ID, Nama = barang.Nama, HargaBeli = barang.HargaBeli, HargaJual = barang.HargaJual, KategoriID = barang.KategoriID, LokasiID = barang.LokasiID, KategoriLookup = context.Kategoris, LokasiLookup = context.Lokasis }; return(viewModel); }