public ActionResult RejectInvoice(AddInvoiceViewModel viewModel) { string errorMessage = ""; prepcode = this.PrepCode; // Format reason string. string reason = DateTime.Now.ToString() + " " + prepcode; reason += " - " + viewModel.REJECTOPTION + " / " + viewModel.REJECTDESCRIPTION; // Mark invoice as rejected. if (!RejectPegasysInvoice(viewModel)) { errorMessage = "Reject invoice failed. "; } // Write transhist entry. string memo = "Image Rejected from data entry - " + reason; var mgrTH = new TransHistManager(); TRANSHIST th = CreateTransHistForChange(viewModel, memo, DataEntry.ImgReject); mgrTH.InsertTransHist(th); // Update imagelist. var mgrIL = new ImageListManager(); IMAGELIST il = mgrIL.GetImageListByImageId(viewModel.IMAGEID); if (il != null) { // Mark as rejected and update. mgrIL.RejectImageList(viewModel.IMAGEID, prepcode, reason); } else { var mgrILH = new ImageListHistManager(); IMAGELISTHIST ilh = mgrILH.GetImageListHistByImageId(viewModel.IMAGEID); if (ilh != null) { // Convert to ImageList and mark as rejected. il = mgrIL.MapToImageList(ilh); MarkImageListAsRejected(il, reason); // Add to ImageList. mgrIL.InsertImageList(il); // Remove from ImageListHist. mgrILH.DeleteImageListHist(ilh); } else { // Uh oh. No imagelisthist entry. errorMessage += viewModel.IMAGEID + " does not exist in the ImageListHist table."; } } // Reload the index page to move to the next invoice, if available. TempData["ErrorMessage"] = errorMessage; return(RedirectToAction("Index", new { InvoiceType = viewModel.INVOICETYPE })); }
public ActionResult AddInvoice(AddInvoiceViewModel viewModel) { prepcode = this.PrepCode; // Key this invoice. if (!KeyPegasysInvoice(viewModel)) { TempData["ErrorMessage"] = "Update failed for invoice " + viewModel.INV_KEY_ID; } // Write transhist entries. string memo = ""; string allProcess = ""; switch (viewModel.INVOICETYPE) { case DataEntry.TypeTops: memo = DataEntry.TopsMemo; allProcess = DataEntry.TopsAllProcess; break; case DataEntry.TypeNonTops: memo = (viewModel.GENE043S ? DataEntry.NonTopsMemoError : DataEntry.NonTopsMemo); allProcess = DataEntry.NonTopsAllProcess; break; case DataEntry.TypeConst: memo = (viewModel.GENE043S ? DataEntry.ConstMemoError : DataEntry.ConstMemo); allProcess = DataEntry.ConstAllProcess; break; case DataEntry.TypeNonConst: memo = DataEntry.NonConstMemo; allProcess = DataEntry.NonConstAllProcess; break; default: // Shouldn't get here. break; } var mgrTH = new TransHistManager(); TRANSHIST th = CreateTransHistForChange(viewModel, memo, allProcess); mgrTH.InsertTransHist(th); var mgrITH = new ImageTransHistManager(); IMAGETRANSHIST ith = CreateImageTransHistForChange(viewModel, memo); mgrITH.InsertImageTransHist(ith); // Reload the index page to move to the next invoice, if available. return(RedirectToAction("Index", new { InvoiceType = viewModel.INVOICETYPE })); }