public ActionResult SaveItem(BarangModel inputBarang) { BarangRepo saveData = new BarangRepo(); inputBarang.createdBy = Session["name"].ToString(); inputBarang.created = DateTime.Now; if (saveData.Save(inputBarang)) { return(Json(new { status = "berhasil" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { status = "gagal" }, JsonRequestBehavior.AllowGet)); } return(View()); }
public ActionResult SaveBarang(BarangModel paimin) { Session["ID"] = "1"; //menggunakan return JSON BarangRepo barangRepo = new BarangRepo(); paimin.CreatedBy = this.Session["ID"].ToString(); paimin.CreatedDate = DateTime.Now; if (barangRepo.Save(paimin)) { return(Json(new { status = "Berhasil" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { status = "Gagal" }, JsonRequestBehavior.AllowGet)); } return(View()); }