public async Task <ActionResult> DeleteConfirmed(int id) { DocumentWorkFlow documentWorkFlow = await db.ApprovalFlows.FindAsync(id); db.ApprovalFlows.Remove(documentWorkFlow); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "Id,Sender,ProcessName,NoOfApprovals,Approver1Id,Approver2Id,Approver3Id,Approver4Id,Approver5Id,IsEnabled")] DocumentWorkFlow documentWorkFlow) { if (ModelState.IsValid) { db.Entry(documentWorkFlow).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(documentWorkFlow)); }
// GET: DocumentWorkFlows/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DocumentWorkFlow documentWorkFlow = await db.ApprovalFlows.FindAsync(id); if (documentWorkFlow == null) { return(HttpNotFound()); } return(View(documentWorkFlow)); }
async Task <List <ApprovalEntry> > IApprovalService.GenerateApprovalEntries <T>(T value, string key, string processno, int userId) { List <ApprovalEntry> entries = new List <ApprovalEntry>(); try { DocumentWorkFlow flow = db.ApprovalFlows.Where(x => x.ProcessName == key).FirstOrDefault(); if (key == "cash") { //CashRequisition model = db.CashRequisitions.Where(x=>x.No==key).First(); var count = db.ApprovalEntries.Count(); Dictionary <int, string> approvers = new Dictionary <int, string>(); approvers.Add(0, flow.Approver1Id); approvers.Add(1, flow.Approver2Id); approvers.Add(2, flow.Approver3Id); approvers.Add(3, flow.Approver4Id); approvers.Add(4, flow.Approver5Id); for (int i = 0; i < flow.NoOfApprovals; i++) { entries.Add(new ApprovalEntry { No = count + i + 1, Sender = userId.ToString(), ProcessType = key, Sequence = i, ProcessNo = processno, Approver = approvers[i], Status = "Pending" }); } } db.ApprovalEntries.AddRange(entries); db.SaveChanges(); } catch (Exception ex) { throw new Exception("Error Generating Approval Entries", ex); } await Task.Delay(5); return(entries); }