public static WorkflowTaskRegRespObj AddWorkflowTask(RegWorkflowTaskObj regObj, string username) { var response = new WorkflowTaskRegRespObj { Status = new APIResponseStatus { IsSuccessful = false, Message = new APIResponseMessage(), }, }; try { var apiResponse = new APIHelper(APIEndpoints.ADD_WORKFLOW_TASK_ENDPOINT, username, Method.POST).ProcessAPI <RegWorkflowTaskObj, WorkflowTaskRegRespObj>(regObj, out var msg); if (msg.Code == 0 && string.IsNullOrEmpty(msg.TechMessage) && string.IsNullOrEmpty(msg.Message)) { return(apiResponse); } response.Status.Message.FriendlyMessage = msg.Message; response.Status.Message.TechnicalMessage = msg.TechMessage; return(response); } catch (Exception ex) { UtilTools.LogE(ex.StackTrace, ex.Source, ex.GetBaseException().Message); response.Status.Message.FriendlyMessage = "Error Occurred! Please try again later"; response.Status.Message.TechnicalMessage = "Error: " + ex.GetBaseException().Message; return(response); } }
public JsonResult ProcessAddWorkflowTaskRequest(RegWorkflowTaskObj model) { try { #region current user session check 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 })); } #endregion #region model validations if (model == null) { return(Json(new { IsSuccessful = false, Error = "Your session has expired", IsAuthenticated = false })); } if (model.ClientId < 1) { return(Json(new { isauthenticated = true, issuccessful = false, isreload = false, error = "client required " })); } if (model.ProductItemId < 1) { return(Json(new { isauthenticated = true, issuccessful = false, isreload = false, error = "Product Item required " })); } if (model.ProductId < 1) { return(Json(new { isauthenticated = true, issuccessful = false, isreload = false, error = "Product required " })); } if (string.IsNullOrEmpty(model.AssigneeEmail) || model.AssigneeEmail.Length < 0) { return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "Email required" })); } if (string.IsNullOrEmpty(model.DueDate) || model.DueDate.Length < 0) { return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "DueDate is required" })); } if (string.IsNullOrEmpty(model.DueTime) || model.DueTime.Length < 0) { return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "DueTime is required" })); } if (string.IsNullOrEmpty(model.StartDate) || model.StartDate.Length < 0) { return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "StartDate is required" })); } if (string.IsNullOrEmpty(model.TaskDescription) || model.TaskDescription.Length < 0) { return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "TaskDescription is required" })); } if (string.IsNullOrEmpty(model.TaskTitle) || model.TaskTitle.Length < 0) { return(Json(new { IsAuthenticated = true, IsSuccessful = false, IsReload = false, Error = "TaskDescription is required" })); } #endregion var previousWorkflowTaskList = (List <WorkflowTaskObj>)Session["_WorkflowTaskList_"]; #region build request object var requestObj = new RegWorkflowTaskObj { ClientId = model.ClientId, ProductId = model.ProductId, AdminUserId = userData.UserId, Status = 1, ProductItemId = model.ProductItemId, ApprovalLevelId = model.ApprovalLevelId, AssigneeEmail = model.AssigneeEmail, AssigneeId = model.AssigneeId, DueDate = model.DueDate, DueTime = model.DueTime, ExpenseRequisitionId = model.ExpenseRequisitionId, RequestType = model.RequestType, IsEmailSent = model.IsEmailSent, StartDate = model.StartDate, StartTime = model.StartTime, TaskDescription = model.TaskDescription, TaskTitle = model.TaskTitle, TimeStampCreated = DateTime.Now.ToString("D"), WorkflowSettingId = model.WorkflowSettingId, }; #endregion #region request and response validations var response = WorkflowTaskServices.AddWorkflowTask(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 })); } #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" })); } }