public ActionResult Create(NcrVM ncrVM) { if (ModelState.IsValid) { Ncr ncr = ncrVM.Ncr; string caseNo; HseqCaseFile hseqCaseFile; ncr.CreatedBy = _RecordService.GetCurrentUser().FullName; ncr = (Ncr)_RecordService.CreateCaseFile(ncr, out caseNo, out hseqCaseFile, db); db.NcrRecords.Add(ncrVM.Ncr); db.SaveChanges(); //create the folder in Alfresco and return the alfresconoderef //Dummy for now //int alfresconoderef = caseNo; //hseqCaseFile.AlfrescoNoderef = caseNo; //ncr.AlfrescoNoderef = caseNo; //Create Approvals if (ncrVM.ProposedDisposition) { HseqApprovalRequest hseqApprovalRequest = ncrVM.HseqApprovalRequest; HseqApprovalRequest approvalRequest = _DelegatableService.AddHseqApprovalRequest(ncr, hseqApprovalRequest, db); Ncr ncr2 = db.NcrRecords.Find(ncr.HseqRecordID); ncr2.Delegatables.Add(approvalRequest); db.SaveChanges(); } return(RedirectToAction("Index")); } else { var errors = ModelState.Values.SelectMany(v => v.Errors); Console.WriteLine(errors); } ncrVM.DetectedInAreas = db.BusinessAreas; ncrVM.ResponsibleAreas = db.BusinessAreas; ncrVM.DiscrepancyTypes = db.DiscrepancyTypes; ncrVM.Coordinators = db.HseqUsers; ncrVM.DispositionTypes = db.DispositionTypes; ncrVM.ApprovalOwners = db.HseqUsers; return(View(ncrVM)); }
public ActionResult Create(DelegatableVM ncrVM) { HseqRecord hseqRecord = null; if (ModelState.IsValid) { hseqRecord = db.HseqRecords.Find(ncrVM.HseqApprovalRequest.HseqRecordID); ncrVM.HseqRecord = hseqRecord; HseqApprovalRequest hseqApprovalRequest = ncrVM.HseqApprovalRequest; if (hseqRecord.RecordType == RecordType.NCR) { Ncr ncr = db.NcrRecords.Find(ncrVM.HseqRecord.HseqRecordID); ncr.NcrState = NcrState.DispositionProposed; ncr.DateLastUpdated = DateTime.Now; } else { hseqRecord.DateLastUpdated = DateTime.Now; } HseqApprovalRequest approvalRequest = _DelegatableService.AddHseqApprovalRequest(hseqRecord, hseqApprovalRequest, db); //ncr.Delegatables.Add(approvalRequest); db.SaveChanges(); return(RedirectToAction("OpenAction", "HseqApprovalRequests")); } else { var errors = ModelState.Values.SelectMany(v => v.Errors); Console.WriteLine(errors); } return(View(ncrVM)); }