public JsonResult ProcessAddWorkflowDetailRequest(RegWorkflowDetailObj model) { try { #region model validations var userData = MvcApplication.GetUserData(User.Identity.Name) ?? new UserData(); if (userData.UserId < 1) { return(Json(new { IsSuccessful = false, Error = "Your session has expired", IsAuthenticated = false })); } if (model.Status < 1) { return(Json(new { IsSuccessful = false, Error = "Task Status required to save changes", IsAuthenticated = true })); } if (model.Recommendation.Length < 5) { return(Json(new { IsSuccessful = false, Error = "Minimium of five characters for recommendation required", IsAuthenticated = true })); } if (string.IsNullOrEmpty(model.Recommendation) || model.Recommendation.Length < 1 || model.Recommendation.Length == 0) { return(Json(new { IsSuccessful = false, Error = "Recommendation field required to save changes", IsAuthenticated = true })); } #endregion #region current task session check var currentTask = (WorkflowTaskObj)Session["_CurrentSelWorkflowTask_"]; if (currentTask == null) { return(Json(new { IsSuccessful = false, Error = "Your session has expired", IsAuthenticated = false })); } #endregion #region build request object var requestObj = new RegWorkflowDetailObj { ClientId = currentTask.ClientId, ProductId = currentTask.ProductId, AdminUserId = userData.UserId, ApprovalLevelId = currentTask.ApprovalLevelId, AssigneeId = currentTask.AssigneeId, ExpenseRequisitionId = currentTask.ExpenseRequisitionId, IsEmailSent = currentTask.IsEmailSent, Recommendation = model.Recommendation.Trim(), RequestType = currentTask.RequestType, TaskTitle = currentTask.TaskTitle, TimeStampRegistered = DateTime.Now.ToString("dddd-mmmm-yyyy"), WorkflowTaskId = currentTask.WorkflowTaskId, Status = model.Status, }; #endregion #region Request and response validations var response = WorkflowDetailServices.AddWorkflowDetail(requestObj, userData.Username); if (response?.Status == null) { return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Error Occurred! Please try again later" })); } if (!response.Status.IsSuccessful) { return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = string.IsNullOrEmpty(response.Status.Message.TechnicalMessage) ? "Process Failed! Unable to add nomination Source" : response.Status.Message.TechnicalMessage })); } var searchObj = new WorkflowDetailSearchObj { AdminUserId = userData.UserId, WorkflowDetailId = 0, Status = -2 }; var retVal = WorkflowDetailServices.LoadWorkflowDetails(searchObj, userData.Username); if (retVal?.Status != null && retVal.WorkflowDetails != null) { var WorkflowDetails = retVal.WorkflowDetails.OrderBy(m => m.WorkflowDetailId).Where(m => m.ClientId == currentTask.ClientId && m.ProductId == currentTask.ProductId).ToList(); Session["_WorkflowDetailList_"] = WorkflowDetails; } #endregion return(Json(new { IsAuthenticated = true, IsSuccessful = true, IsReload = false, Error = "" })); } catch (Exception ex) { UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message); return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Process Error Occurred! Please try again later" })); } }
public PartialViewResult RecommendationList(int ExpenseRequisitionId) { try { ViewBag.Error = ""; ViewBag.SessionError = ""; #region current user session check var userData = MvcApplication.GetUserData(User.Identity.Name) ?? new UserData(); if (userData.UserId < 1) { ViewBag.SessionError = "Your session has expired! Please re-login"; return(PartialView(new List <WorkflowDetailObj>())); } #endregion #region Id check if (ExpenseRequisitionId < 1) { ViewBag.Error = "Invalid selection"; return(PartialView(new List <WorkflowDetailObj>())); } #endregion #region get approval work flow level name from session or service if session is empty if (Session["_ApprovalLevels_"] is List <WorkFlowApprovalLevelObj> WorkFlowApprovalLevelList && WorkFlowApprovalLevelList.Any()) { Session["_ApprovalLevels_"] = WorkFlowApprovalLevelList.ToList(); } else { var reqObjAppLvel = new WorkFlowApprovalLevelSearchObj { AdminUserId = userData.UserId, StartDate = " ", Status = -2, StopDate = "", WorkFlowApprovalLevelId = 0, }; var retValForAppLv = ExpenseLookUpServices.LoadWorkFlowApprovalLevels(reqObjAppLvel, userData.Username); var appLevels = retValForAppLv.WorkflowApprovalLevels.ToList(); Session["_ApprovalLevels_"] = appLevels; } #endregion #region return Approval levels comment if session is not null if (Session["_WorkflowComments_"] is List <WorkflowDetailObj> WorkflowDetailList && WorkflowDetailList.Any()) { return(PartialView(WorkflowDetailList.Where(m => m.ExpenseRequisitionId == ExpenseRequisitionId && m.Status != (int)WorkflowStatus.Processing).ToList())); } #endregion #region requests for approval level comments and response check var reqObj = new WorkflowDetailSearchObj { AdminUserId = userData.UserId, StartDate = " ", Status = -2, StopDate = "", WorkflowDetailId = 0, }; var retVal = WorkflowDetailServices.LoadWorkflowDetails(reqObj, userData.Username); var thisWorkflowComments = retVal.WorkflowDetails.Where(m => m.ExpenseRequisitionId == ExpenseRequisitionId && m.Status != (int)WorkflowStatus.Processing).ToList(); if (thisWorkflowComments == null || !thisWorkflowComments.Any()) { ViewBag.Error = "Error Occurred! Unable to process selected item"; return(PartialView(new List <WorkflowDetailObj>())); } Session["_WorkflowComments_"] = thisWorkflowComments; #endregion return(PartialView(thisWorkflowComments)); } catch (Exception ex) { ViewBag.Error = "Error Occurred! Please try again later"; UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message); return(PartialView(new List <WorkflowDetailObj>())); } }