public ResponseMessage WorkflowSiteRequirement(WorkFlowSiteReqPayload reqPayload) { ResponseMessage responseMessage = new ResponseMessage(); responseMessage = _siteRequirementRepository.WorkflowSiteRequirement(reqPayload); return(responseMessage); }
public ResponseMessage WorkflowSiteRequirement(WorkFlowSiteReqPayload reqPayload) { try { ResponseMessage resp = new ResponseMessage(); if (reqPayload.mode == commonEnum.WorkFlowMode.Approval) { var siteRequirements = _context.Database.ExecuteSqlCommand("exec sp_ApprovalRequirement {0}, {1},{2}", reqPayload.siteReqId, reqPayload.role_name.ToString(), null); resp.Message = string.Format("Requirement successfully Approved by {0}", reqPayload.role_name); if (siteRequirements == -1) { throw new ValueNotFoundException("Approval opearation not allowed "); } } else if (reqPayload.mode == commonEnum.WorkFlowMode.Rejection) { var siteRequirements = _context.Database.ExecuteSqlCommand("exec sp_RejectRequirement {0}, {1}, {2}", reqPayload.siteReqId, reqPayload.role_name.ToString(), reqPayload.role_hierarchy); resp.Message = string.Format("Requirement successfully Rejected by {0}", reqPayload.role_name); if (siteRequirements == -1) { throw new ValueNotFoundException("Rejection opearation not allowed"); } } return(resp); } catch (Exception ex) { throw ex; } }
public IActionResult WorkflowManagement(WorkFlowSiteReqPayload siteRequirement) { try { var response = _sitereqService.WorkflowSiteRequirement(siteRequirement); return(StatusCode(StatusCodes.Status204NoContent, (new { message = response.Message, code = 204 }))); } catch (ValueNotFoundException e) { Util.LogError(e); return(StatusCode(StatusCodes.Status422UnprocessableEntity, new ErrorClass() { code = StatusCodes.Status422UnprocessableEntity.ToString(), message = e.Message })); } catch (Exception e) { Util.LogError(e); return(StatusCode(StatusCodes.Status500InternalServerError, new ErrorClass() { code = StatusCodes.Status500InternalServerError.ToString(), message = "Something went wrong" })); } }