public ActionResult Cancel(BatchTestViewModel model) { ResponseResult result = BatchRepo.Cancel(model); return(Json(new { success = result.Success, message = result.ErrorMessage, entity = result.Entity }, JsonRequestBehavior.AllowGet)); }
//Setup Test Cancel public static ResponseResult Cancel(BatchTestViewModel entity) { ResponseResult result = new ResponseResult(); try { using (var db = new XBC_Context()) { t_batch_test bt = db.t_batch_test.Where(o => o.batch_id == entity.batch_id && o.test_id == entity.test_id).FirstOrDefault(); if (bt != null) { db.t_batch_test.Remove(bt); db.SaveChanges(); result.Entity = entity; // Audit Log Delete var Serial = new JavaScriptSerializer(); object data = new //Mengambil Data Json { bt.batch_id, bt.test_id }; //var json = new JavaScriptSerializer().Serialize(bt); t_audit_log log = new t_audit_log(); log.type = "DELETE"; log.json_delete = Serial.Serialize(data);; log.created_by = entity.UserId; log.created_on = DateTime.Now; db.t_audit_log.Add(log); db.SaveChanges(); result.Entity = entity; } else { result.Success = false; result.ErrorMessage = "Test Not Found"; } } } catch (Exception ex) { result.Success = false; result.ErrorMessage = ex.Message; } return(result); }
// Setup Test Choose public static ResponseResult Choose(BatchTestViewModel entity) { ResponseResult result = new ResponseResult(); try { using (var db = new XBC_Context()) { if (entity.id == 0) // Choose { t_batch_test bt = new t_batch_test(); bt.batch_id = entity.batch_id; bt.test_id = entity.test_id; bt.created_by = entity.UserId; bt.created_on = DateTime.Now; db.t_batch_test.Add(bt); db.SaveChanges(); // Audit Log Insert var json = new JavaScriptSerializer().Serialize(bt); t_audit_log log = new t_audit_log(); log.type = "INSERT"; log.json_insert = json; log.created_by = entity.UserId; log.created_on = DateTime.Now; db.t_audit_log.Add(log); db.SaveChanges(); entity.id = bt.id; result.Entity = entity; } else { result.Success = false; result.ErrorMessage = "Gagal Mensetup Test"; } } } catch (Exception ex) { result.Success = false; result.ErrorMessage = ex.Message; } return(result); }
// Mengechek Setup TestList public static BatchTestViewModel Check(long b_id, long t_id) { BatchTestViewModel result = new BatchTestViewModel(); using (var db = new XBC_Context()) { result = (from bt in db.t_batch_test where bt.batch_id == b_id && bt.test_id == t_id select new BatchTestViewModel { id = bt.id, batch_id = bt.batch_id }).FirstOrDefault(); } return(result == null ? result = new BatchTestViewModel() : result); }
// Set Up Test List public ActionResult SetUpTest(long id) { ViewBag.IdBatch = id; // mengirim bath id List <TestViewModel> data = TestRepo.All(""); foreach (var item in data) { BatchTestViewModel btmodel = BatchRepo.Check(id, item.id); if (btmodel.batch_id == 0) { item.check = true; } else { item.check = false; } } return(PartialView("_SetUpTest", data)); }