示例#1
0
        internal ApiResult SaveTimeBoundAccessRequest(TimeBoundAccessRequest req)
        {
            ApiResult apiResult = new ApiResult();

            try
            {
                if (!req.IsValid())
                {
                    apiResult.SetFailuresAsStatusInResponseFields(req.StatusDesc);
                    return(apiResult);
                }

                req.Save();

                if (req.Status != "PENDING")
                {
                    apiResult.PegPayID = req.Id.ToString();
                    apiResult.SetSuccessAsStatusInResponseFields();
                    return(apiResult);
                }

                ApiResult sendResult = NotificationsHandler.SendApproveTbarEmail(req);

                if (sendResult.StatusCode != Globals.SUCCESS_STATUS_CODE)
                {
                    apiResult.PegPayID = req.Id.ToString();
                    apiResult.SetFailuresAsStatusInResponseFields("FAILED TO SEND EMAIL TO APPROVER: " + sendResult.StatusDesc);
                    return(apiResult);
                }


                apiResult.SetSuccessAsStatusInResponseFields();
            }
            catch (Exception ex)
            {
                HandleError(nameof(AttachSystemAffectedToChangeRequest), "EXCEPTION", ex.Message);
                apiResult.SetFailuresAsStatusInResponseFields(ex.Message);
            }
            return(apiResult);
        }
 public ApiResult SendApproveTbarEmail(TimeBoundAccessRequest tbar) => NotificationsHandler.SendApproveTbarEmail(tbar);