public ActionResult HapusBarang(DetailPembelianViewModel model)
 {
     if (PembelianRepo.HapusBarang(model))
     {
         return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
     }
     else
     {
         return(Json(new { success = false, message = PembelianRepo.Message }, JsonRequestBehavior.AllowGet));
     }
 }
Beispiel #2
0
        public static DetailPembelianViewModel GetDetailById(int id)
        {
            DetailPembelianViewModel result = new DetailPembelianViewModel();

            using (var db = new PosContext())
            {
                result = (from d in db.Mst_DetailBarangs
                          join b in db.Mst_Barangs
                          on d.IdBarang equals b.Id
                          //join h in db.Trans_HeaderPenjualans
                          //on d.IdHeaderPenjualan equals h.Id
                          where d.Id == id
                          select new DetailPembelianViewModel
                {
                    IdDetailBarang = d.Id,
                    IdSupplier = d.IdSupplier,
                    CodeBarang = b.Code,
                    Deskripsi = b.Deskripsi,
                    HargaPembelian = d.HargaPembelian
                }).FirstOrDefault();
            }
            return(result);
        }
Beispiel #3
0
        public static bool HapusBarang(DetailPembelianViewModel model)
        {
            bool result = true;

            try
            {
                using (var db = new PosContext())
                {
                    DetailPembelian es = db.Trans_DetailPembelians.Where(o => o.IdHeaderPembelian == model.IdHeaderPembelian && o.IdDetailBarang == model.IdDetailBarang).FirstOrDefault();
                    if (es != null)
                    {
                        db.Trans_DetailPembelians.Remove(es);
                        db.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                Message = ex.Message;
                result  = false;
            }
            return(result);
        }