public IActionResult BankDetails(mdlFilterModel mdl, enmLoadData submitdata, [FromServices] IConsProfile consProfile) { mdlTcBankReportWraper returnData = new mdlTcBankReportWraper(); if (mdl.dateFilter == null) { mdl.dateFilter = new mdlDateFilter(); } if (mdl.idFilter == null) { mdl.idFilter = new mdlIdFilter(); } mdl.dateFilter.FromDt = Convert.ToDateTime(mdl.dateFilter.FromDt.ToString("dd-MMM-yyyy")); mdl.dateFilter.ToDt = Convert.ToDateTime(mdl.dateFilter.ToDt.AddDays(1).ToString("dd-MMM-yyyy")); returnData.TcBankWrapers = consProfile.GetBankDetails(submitdata, mdl, 0, false); returnData.FilterModel = mdl; return(View(returnData)); }
public async Task <IActionResult> BankApprovalAsync(mdlTcBankWraper mdl, string submitdata, [FromServices] IConsProfile consProfile) { try { ModelState.Clear(); if (submitdata == "LoadData") { if (mdl.TcId == "") { ModelState.AddModelError(nameof(mdl.TcId), "TcId Required"); } else { mdl = consProfile.GetBankDetails(enmLoadData.ByID, new mdlFilterModel() { idFilter = new mdlIdFilter() { TcId = mdl.TcId } }, 0, true).FirstOrDefault(); } return(View(mdl)); } else if (submitdata == "Approve" || submitdata == "Reject") { bool HaveModelError = false; if (mdl.DetailId == 0) { HaveModelError = true; ModelState.AddModelError("", "Invalid Data"); } if (submitdata == "Reject" && (string.IsNullOrWhiteSpace(mdl.ApprovalRemarks))) { HaveModelError = true; ModelState.AddModelError(nameof(mdl.ApprovalRemarks), "Remarks Required"); } if (!HaveModelError) { var data = _context.tblTcBankDetails.Where(p => p.DetailId == mdl.DetailId).FirstOrDefault(); if (data == null) { HaveModelError = true; ModelState.AddModelError("", "Invalid Data"); } else { data.IsApproved = submitdata == "Approve" ? enmApprovalType.Approved : enmApprovalType.Rejected; data.ApprovalRemarks = mdl.ApprovalRemarks; data.ApprovedBy = _currentUsers.EmpId; data.ApprovedDt = DateTime.Now; _context.Update(data); await _context.SaveChangesAsync(); return(RedirectToAction("BankApproval", new { _enmSaveStatus = enmSaveStatus.success, _enmMessage = submitdata == "Approve" ? enmMessage.ApprovedSucessfully: enmMessage.RejectSucessfully })); } } if (HaveModelError) { ViewBag.SaveStatus = (int)enmSaveStatus.danger; ViewBag.Message = enmMessage.InvalidData; } } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); } if (mdl == null) { mdl = new mdlTcBankWraper(); } return(View(mdl)); }