public ActionResult Index(long id = 0, long code = 0) { if (id != 0) { try { Workflow workflow = this.workflowService.GetDataById(id); DocumentMappingModel model = new DocumentMappingModel(); //get workflowId model.WorkflowId = id; model.NodeId = code.ToString(); model.SecuredId = Base.Encrypt(id.ToString()); //populate document list model.DocumentList = this.service.GetDocumentList(0, 0); //node model.WorkflowName = string.Format("{0} : {1}", workflow.Code, workflow.Name); model.ProcessList = this.service.GetProcessList(0); if (model != null) return View(model); } catch (Exception) { } } return RedirectToAction("Index","Workflow"); }
public ActionResult AddDocument(DocumentMappingModel model) { if (ModelState.IsValid) { DocumentMapping documentMapping = new DocumentMapping(); List<DocumentMapping> currentDocumentMapping = GetCurrentDocumentMapping(); documentMapping.Mandatory = model.Mandatory; documentMapping.Document = this.documentService.GetDataById(model.DocumentId); documentMapping.Workflow = this.workflowService.GetDataById(model.WorkflowId); if (currentDocumentMapping.Any()) { if (!currentDocumentMapping.Exists(x => x.Document.Id.Equals(documentMapping.Document.Id))) { model.DocumentMappingList.Add(documentMapping); currentDocumentMapping.Add(documentMapping); } else { ModelState.AddModelError("StatusError", "already added"); return Json(new { result = StatusCode.existed, message = MessageCode.existed, code = StatusCode.existed }); } } else { currentDocumentMapping.Add(documentMapping); } model.DocumentMappingList = currentDocumentMapping; if (Request.IsAjaxRequest()) { return PartialView("Partial/Document", model); } return Json(new { result = StatusCode.saved, message = MessageCode.saved, code = StatusCode.saved }); } return Json(new { result = StatusCode.failed, message = MessageCode.error, code = StatusCode.invalid }); }
public ActionResult Index(long id) { if(id!=0) { try { DocumentMappingModel model = new DocumentMappingModel(); model.WorkflowId = id; model.WorkflowList = this.service.GetWorkflowList(id,id); model.DocumentList = this.service.GetDocumentList(0, 0); model.SecuredId= Base.Encrypt(id.ToString()); model.DocumentMappingList = GetCurrentDocumentMapping() ?? null; if (model != null) return View(model); } catch (Exception) { } } return RedirectToAction("Index"); }
public ActionResult SaveDocumentMapping(DocumentMappingModel model) { try { List<DocumentMapping> currentDocumentMapping = GetCurrentDocumentMapping(); if (currentDocumentMapping.Any()) { foreach (var document in currentDocumentMapping) { bool ifExists = this.documentMappingService.CheckDataIfExists(document); if (!ifExists) { document.CreatedBy = User.Identity.Name; document.DateCreated = DateTime.Now; document.Active = true; this.documentMappingService.Save(document); } } ClearSession(); return Json(new { result = Base.Encrypt(model.WorkflowId.ToString()), message = MessageCode.saved, code = StatusCode.saved, content = MessageCode.saved }); } return Json(new { result = StatusCode.failed, message = MessageCode.error, code = StatusCode.invalid, content = MessageCode.error }); } catch (Exception ex) { return Json(new { result = MessageCode.error, message = MessageCode.error, code = StatusCode.invalid, content = ex.Message.ToString() }); } }
public ActionResult RemoveDocument(int id) { DocumentMappingModel model = new DocumentMappingModel(); List<DocumentMapping> currentDocumentMapping = RemoveItemFromCurrentDocumentMapping(id); model.DocumentMappingList = currentDocumentMapping; if (Request.IsAjaxRequest()) { return PartialView("Partial/Document", model); } return View(model); }
public ActionResult Modify(string code) { if (!string.IsNullOrEmpty(code)) { DocumentMappingModel model = new DocumentMappingModel(); DocumentMapping currentDocumentMapping = GetItemFromCurrentDocumentMapping(code); model.Document = currentDocumentMapping.Document; model.Active = currentDocumentMapping.Active; model.Mandatory = currentDocumentMapping.Mandatory; return View(model); } return View(); }