public ActionResult Reject(decimal AuthId, int?m, string Narration) { try { var rec2 = repoAuth.Find(AuthId); if (rec2 == null) { respMsg = "Problem processing request. Try again or contact Administrator."; //TempData["msg"] = respMsg; //return RedirectToAction("DetailAuth", new { a_i = SmartObj.Encrypt(rec2.ITBID.ToString()), m = SmartObj.Encrypt(rec2.MENUID.GetValueOrDefault().ToString()) }); return(Json(new { RespCode = 1, RespMessage = respMsg })); } else if (rec2.STATUS.ToLower() != "open") { respMsg = "This request has already been processed by an authorizer."; //TempData["msg"] = respMsg; //return RedirectToAction("DetailAuth", new { a_i = SmartObj.Encrypt(AuthId.ToString()), m = SmartObj.Encrypt(m.GetValueOrDefault().ToString()) }); return(Json(new { RespCode = 1, RespMessage = respMsg })); } int recordId = 0; // bool suc = false; //using (var txscope = new TransactionScope(TransactionScopeOption.RequiresNew)) //{ var d = new AuthListUtil(); //menuId = 5; var dd = d.GetCheckerRecord(m.GetValueOrDefault(), AuthId, 0, institutionId); if (dd.authListObj.Count < checkerNo) { var chk = new SM_AUTHCHECKER() { AUTHLIST_ITBID = AuthId, CREATEDATE = DateTime.Now, NARRATION = Narration, STATUS = reject, USERID = User.Identity.Name, }; repoAuthChecker.Insert(chk); var rst = uow.Save(User.Identity.Name); if (rst > 0) { var noA = dd.authListObj.Where(f => f.CHECKERSTATUS == approve).Count(); noA += 1; if (noA == checkerNo) { recordId = (int)rec2.RECORDID; //menuId = rec2.MENUID.GetValueOrDefault(); var recc = repoFreqTemp.Find(recordId); if (recc != null) { recc.STATUS = reject; } rec2.STATUS = reject; var t = uow.Save(User.Identity.Name); if (t > 0) { sucNew = true; // txscope.Complete(); } } } } //} if (sucNew) { EmailerNotification.SendApprovalRejectionMail(rec2.USERID, rec2.EVENTTYPE, reject, "Frequency Rejection", null, fullName); respMsg = "Record Rejected. A mail has been sent to the user."; return(Json(new { RespCode = 0, RespMessage = respMsg, status = reject })); } respMsg = "Problem processing request. Try again or contact Administrator."; return(Json(new { RespCode = 1, RespMessage = respMsg })); } catch (Exception ex) { //return Json(new { RespCode = 99, RespMessage = "Problem processing request. Try again or contact Administrator." }); respMsg = "Problem processing request. Try again or contact Administrator."; TempData["msg"] = respMsg; return(RedirectToAction("DetailAuth", new { a_i = SmartObj.Encrypt(AuthId.ToString()), m = SmartObj.Encrypt(m.GetValueOrDefault().ToString()) })); } }
public ActionResult Approve(decimal AuthId, int?m) { var sucNew = false; try { //int menuId; //var mid = SmartObj.Decrypt(m); //var ai = SmartObj.Decrypt(a_i); //if (int.TryParse(mid, out menuId) && decimal.TryParse(ai, out authId)) //{ var obj = new AuthViewObj(); var rec2 = repoAuth.Find(AuthId); if (rec2 == null) { respMsg = "Problem processing request. Try again or contact Administrator."; //TempData["msg"] = respMsg; //return RedirectToAction("DetailAuth", new { a_i = SmartObj.Encrypt(rec2.ITBID.ToString()), m = SmartObj.Encrypt(rec2.MENUID.GetValueOrDefault().ToString()) }); return(Json(new { RespCode = 1, RespMessage = respMsg })); } else if (rec2.STATUS.ToLower() != "open") { respMsg = "This request has already been processed by an authorizer."; //TempData["msg"] = respMsg; //return RedirectToAction("DetailAuth", new { a_i = SmartObj.Encrypt(AuthId.ToString()), m = SmartObj.Encrypt(m.GetValueOrDefault().ToString()) }); return(Json(new { RespCode = 1, RespMessage = respMsg })); } int recordId = 0; bool suc = false; //using (var txscope = new TransactionScope(TransactionScopeOption.RequiresNew)) //{ var d = new AuthListUtil(); //menuId = 5; var dd = d.GetCheckerRecord(m.GetValueOrDefault(), AuthId, 0, institutionId); if (dd.authListObj.Count < checkerNo) { var chk = new SM_AUTHCHECKER() { AUTHLIST_ITBID = authId, CREATEDATE = DateTime.Now, NARRATION = null, STATUS = approve, USERID = User.Identity.Name, }; repoAuthChecker.Insert(chk); var rst = uow.Save(User.Identity.Name); if (rst > 0) { var noA = dd.authListObj.Where(f => f.CHECKERSTATUS == approve).Count(); noA += 1; if (noA == checkerNo) { recordId = (int)rec2.RECORDID; menuId = rec2.MENUID.GetValueOrDefault(); switch (rec2.EVENTTYPE) { case "New": { suc = CreateMainRecord(recordId); break; } case "Modify": { suc = ModifyMainRecord(recordId); break; } case "CLOSE": { suc = CloseMainRecord(recordId); break; } default: { break; } } // rec2.STATUS = close; if (suc) { rec2.STATUS = approve; var t = uow.Save(rec2.USERID, User.Identity.Name); if (t > 0) { sucNew = true; //txscope.Complete(); } } else { //return Json(new { RespCode = 99, RespMessage = "Problem processing request. Try again or contact Administrator." }); respMsg = "Problem processing request. Try again or contact Administrator."; // TempData["msg"] = respMsg; // return RedirectToAction("DetailAuth", new { a_i = SmartObj.Encrypt(rec2.ITBID.ToString()), m = SmartObj.Encrypt(rec2.MENUID.GetValueOrDefault().ToString()) }); return(Json(new { RespCode = 1, RespMessage = respMsg })); } } //if (!isApprove) //{ // pnlResponse.Visible = true; // pnlResponse.CssClass = "alert alert-success alert-dismissable alert-bold fade in"; // pnlResponseMsg.Text = "Record Successfully Approved"; //} } } //else //{ // //bad request // respMsg = "Problem processing request. Try again or contact Administrator."; // // TempData["msg"] = respMsg; // // return RedirectToAction("DetailAuth", new { a_i = SmartObj.Encrypt(AuthId.ToString()) , m = SmartObj.Encrypt(m.GetValueOrDefault().ToString()) }); // return Json(new { RespCode = 1, RespMessage = respMsg }); //} //} if (sucNew) { EmailerNotification.SendApprovalRejectionMail(rec2.USERID, rec2.EVENTTYPE, approve, "Currency Approval", null, fullName); respMsg = "Record Authorized Successfully. A mail has been sent to the user."; return(Json(new { RespCode = 0, RespMessage = respMsg, status = approve })); } respMsg = "This request has already been processed by an authorizer."; return(Json(new { RespCode = 1, RespMessage = respMsg })); } catch (Exception ex) { //return Json(new { RespCode = 99, RespMessage = "Problem processing request. Try again or contact Administrator." }); respMsg = "Problem processing request. Try again or contact Administrator."; // TempData["msg"] = respMsg; // return RedirectToAction("DetailAuth", new { a_i = SmartObj.Encrypt(AuthId.ToString()) , m = SmartObj.Encrypt(m.GetValueOrDefault().ToString()) }); return(Json(new { RespCode = 1, RespMessage = respMsg })); } }