예제 #1
0
        public BarangCreateEditViewModel GetBarangCreateViewModel()
        {
            var viewModel = new BarangCreateEditViewModel();

            viewModel.KategoriLookup = context.Kategoris;
            viewModel.LokasiLookup   = context.Lokasis;

            return(viewModel);
        }
예제 #2
0
        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();
        }
예제 #3
0
        public ActionResult Edit(BarangCreateEditViewModel model)
        {
            try
            {
                barangProvider.EditBarang(model);

                return(RedirectToAction("Index"));
            }
            catch (Exception)
            {
                return(RedirectToAction("Edit"));
            }
        }
예제 #4
0
 public ActionResult Create(BarangCreateEditViewModel model)
 {
     try
     {
         barangProvider.AddBarang(model);
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         throw ex;
         return(RedirectToAction("Create"));
     }
 }
예제 #5
0
        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();
        }
예제 #6
0
        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);
        }