public JsonResult Simpan([FromBody] dynamic data) { // Console.WriteLine(items); bool save = false; List <Input> items = data.ToObject <List <Input> >(); foreach (Input item in items) { // DateTime tgl= System.DateTime.Now; // item.tgl_produksi = tgl; // item.tgl_cetak = tgl; if (ModelState.IsValid) { db.Add(item); db.SaveChanges(); save = true; } } return(Json(save)); }
public JsonResult Update([FromBody][Bind("id,code,id_controller,type_controller,ip_controller,barang,lot_no,counter,tare,kemasan,location,id_printer,type_printer,ip_printer,path,id_dig_scale,type_dig_scale")] dynamic data) { bool save = false; //data.code = "CR"; List <Setting> items = data.ToObject <List <Setting> >(); foreach (Setting item in items) { item.code = "CR"; if (ModelState.IsValid) { db.Update(item); db.SaveChanges(); save = true; } } return(Json(save)); }
public ActionResult AddTimb(Setting item) { var max_id = db.m_code.Where(c => c.code == "SC").Select(c => c.id_dig_scale).Max(); item.code = "SC"; if (ModelState.IsValid) { db.Add(item); db.SaveChanges(); return(RedirectToAction("Timb")); } return(View()); }