//[Authorize(User = "******")] public ActionResult Edit(int id, [Bind("policy_Id,cycleDate,CylceDateNotes")] PolicyCycleDateVM polisVM) { Boolean retval = false; string message = ""; if (id != polisVM.policy_Id) { return(NotFound()); } if (polisVM.cycleDate < 1 || polisVM.cycleDate > 31) { message = " cycleDate harus diantara 1 - 31 ! "; return(Json(new { data = retval, message = message })); } var polis = this.findPolicyModel(id); if (polis == null) { message = " Polis Tidak ditemukan ! "; return(Json(new { data = retval, message = message })); } if (ModelState.IsValid) { try { polis.cycleDate = polisVM.cycleDate; if (polisVM.CylceDateNotes != "") { polis.CylceDateNotes = polisVM.CylceDateNotes; } _context.Update(polis); _context.SaveChanges(); retval = true; message = "sukses"; //flashMessage.Confirmation("Sukses"); } catch (Exception ex) { retval = false; message = ex.Message; //flashMessage.Danger(ex.Message); } } return(Json(new { data = retval, message = message })); }
public ActionResult Edit(int id, [Bind("id,bank_id,RejectCode,RejectReason,GroupRejectMappingID,note")] ReasonMapingGroupEditVM ReasonMapingUpdate) { Boolean retval = false; string message = ""; var reasonGroupModel = this.findRejectModel(id); if (reasonGroupModel == null) { retval = false; message = "Data tidak ditemukan"; return(Json(new { data = retval, message = message })); } int bankid; if (!int.TryParse(ReasonMapingUpdate.bank_id ?? "0", out bankid)) { retval = false; message = "Data tidak ditemukan"; return(Json(new { data = retval, message = message })); } try { reasonGroupModel.bank_id = (bankid == 0 ? (int?)null : bankid); reasonGroupModel.RejectCode = ReasonMapingUpdate.RejectCode; reasonGroupModel.RejectReason = ReasonMapingUpdate.RejectReason; reasonGroupModel.GroupRejectMappingID = int.Parse(ReasonMapingUpdate.GroupRejectMappingID); reasonGroupModel.note = ReasonMapingUpdate.note; _context.Update(reasonGroupModel); _context.SaveChanges(); retval = true; message = "sukses"; } catch (Exception ex) { retval = false; message = ex.Message; } return(Json(new { data = retval, message = message })); }
public ActionResult UploadResult(int id, [Bind("tglProses,FileName")] UploadResultSubmitVM UploadFile) { var tgl = DateTime.Now.Date; if (UploadFile.tglProses < tgl) { ModelState.AddModelError("tglProses", " Tgl Proses harus mulai dari tanggal sekarang Atau setelahnya .... "); } var FileNextProses = _context.FileNextProcessModel.SingleOrDefault(m => m.id == id); if (FileNextProses.FileName != null) { ModelState.AddModelError("FileName", " File sudah pernah di upload, silahkan di remove dulu !"); } var fileUpload = new FileInfo(FileResult + FileNextProses.FileName); if (fileUpload.Exists) { ModelState.AddModelError("FileName", " File dengan nama file tersebut sudah ada, silahkan ubah nama file Upload !"); } if (ModelState.IsValid) { FileNextProses.tglProses = UploadFile.tglProses; FileNextProses.FileName = UploadFile.FileName.FileName.ToString() + Guid.NewGuid().ToString().Substring(0, 8); _context.Update(FileNextProses); _context.SaveChanges(); using (var fileStream = new FileStream(FileResult + FileNextProses.FileName, FileMode.Create)) { UploadFile.FileName.CopyTo(fileStream); } // Proses insert File by Console foreach (Process proc in Process.GetProcessesByName("ExecFileBilling")) { proc.Kill(); } try { var process = new Process(); process.StartInfo.FileName = "dotnet"; process.StartInfo.WorkingDirectory = DirCommand; process.StartInfo.Arguments = ConsoleExecResult + " upload " + id.ToString(); process.StartInfo.UseShellExecute = false; process.StartInfo.CreateNoWindow = true; process.Start(); process.WaitForExit(); flashMessage.Confirmation("Sukses"); } catch (Exception ex) { var fileupload = new FileInfo(FileResult + FileNextProses.FileName); if (fileupload.Exists) { fileupload.Delete(); } FileNextProses.tglProses = null; FileNextProses.FileName = null; _context.Update(FileNextProses); _context.SaveChanges(); flashMessage.Danger(ex.Message); } try { foreach (Process proc in Process.GetProcessesByName("ExecFileBilling")) { proc.Kill(); } } catch (Exception ex) { throw ex; } return(RedirectToAction("index")); } return(View("UploadResult", UploadFile)); }