private void ComposeWokflowSeq(string valueNum, docsdevEntities context, dynamic data, string docKey, signer_employee user, ref int x) { var workflowSequenceInput = Request.Form["workflowSequenceInput" + valueNum + "[]"]; foreach (var value in workflowSequenceInput) { var employee = context.signer_employee.Where(o => o.employee_email == value).FirstOrDefault(); var signer_workflow_item = new signer_workflow { request_id = data.request_id, employee_id = Convert.ToInt32(employee.employee_id), document = docKey, email = employee.employee_email, status = "PENDING", notes = "SEQUENCE", updated_by = Convert.ToInt32(user.employee_id), order_by = x }; context.signer_workflow.Add(signer_workflow_item); //var insertWorkflow = context.SaveChanges(); x++; } context.SaveChanges(); }
private bool ComposeWorkflowNonCombile(signer_requests requestor, docsdevEntities context, dynamic data, string docKey, signer_employee user) { try { var approval = Request.Form["approval[]"]; if (!String.IsNullOrEmpty(approval)) { if (approval.Count == 1) { foreach (var val in approval) { if (user.employee_email == val) { return(false); } } } } context.SaveChanges(); data.request_id = requestor.id; if (requestor.workflow_method == "SEQUENCE") { int index = 0; foreach (var val in approval) { var employee = context.signer_employee.Where(o => o.employee_email == val).FirstOrDefault(); var sw = new signer_workflow { request_id = data.request_id, employee_id = Convert.ToInt32(employee.employee_id), document = docKey, email = employee.employee_email, status = "PENDING", notes = "SEQUENCE", updated_by = Convert.ToInt32(user.employee_id), order_by = index }; context.signer_workflow.Add(sw); //var insertWorkflow = context.SaveChanges(); index++; } context.SaveChanges(); } if (requestor.workflow_method == "PARALEL") { foreach (var val in approval) { var employee = context.signer_employee.Where(o => o.employee_email == val).FirstOrDefault(); var sw = new signer_workflow { request_id = data.request_id, employee_id = Convert.ToInt32(employee.employee_id), document = docKey, email = employee.employee_email, status = "PENDING", notes = "PARALEL", updated_by = Convert.ToInt32(user.employee_id), order_by = 0 }; context.signer_workflow.Add(sw); var insertWorkflow = context.SaveChanges(); } context.SaveChanges(); } } catch (Exception ex) { throw ex; } return(true); }