Exemple #1
0
        public HttpResponseMessage IsUserRegisteredByUserId(int userId)
        {
            try
            {
                bool rtn = guestUserService.IsUserRegistered(userId);

                return(Request.CreateResponse(HttpStatusCode.OK, rtn));
            }
            catch (Exception ex)
            {
                ex.Data.Add("userId", userId);
                ex.Data.Add("HTTPReferrer", "JCRAPI/GuestUser/IsUserRegisteredByUserId");
                WebExceptionHelper.LogException(ex, null);
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "There was an error. Please contact your Program Administrator."));
            }
        }
Exemple #2
0
        public HttpResponseMessage UpdateTaskObservationAssoc([FromBody] TaskObservationAssociation tskObsObj)
        {
            try
            {
                TaskServices.UpdateTaskObservationAssoc(tskObsObj.TracerResponseId, tskObsObj.TaskIDs);

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                ex.Data.Add("tracerResponseId", tskObsObj.TracerResponseId);
                ex.Data.Add("HTTPReferrer", "JCRAPI/TaskInfo/UpdateTaskObservationAssoc");
                WebExceptionHelper.LogException(ex, null);
                return(null);
            }
        }
Exemple #3
0
        public HttpResponseMessage GetTaskLinkInfo(string lnk)
        {
            try
            {
                string errMsg = string.Empty;

                ApiGetTaskLinkDetailsReturnModel taskLink = guestUserService.LookupByTaskLink(lnk);

                return(Request.CreateResponse(HttpStatusCode.OK, taskLink));
            }
            catch (Exception ex)
            {
                WebExceptionHelper.LogException(ex, null);
                return(null);
            }
        }
Exemple #4
0
        public HttpResponseMessage CreateEmailCode(string email)
        {
            try
            {
                string rtn = guestUserService.CreatePasscode(email);

                return(Request.CreateResponse(HttpStatusCode.OK, rtn));
            }
            catch (Exception ex)
            {
                ex.Data.Add("email", email);
                ex.Data.Add("HTTPReferrer", "JCRAPI/GuestUser/GetGuestUserTracersBySiteProgram");
                WebExceptionHelper.LogException(ex, null);
                return(null);
            }
        }
Exemple #5
0
 public HttpResponseMessage GetUserByUserLogonID(string loginID) {
     PasswordServices service = new PasswordServices();
     string rtnMsg = "";
     try {
         var userInfo = service.GetUserByUserLogonID(loginID);
         if (userInfo != null) {
             return Request.CreateResponse(HttpStatusCode.OK, userInfo);
         } else {
             return Request.CreateErrorResponse(HttpStatusCode.NotFound, rtnMsg);
         }
     } catch (Exception ex) {
         ex.Data.Add("loginID", loginID);
         ex.Data.Add("HTTPReferrer", "JCRAPI/PasswordInfo/GetUserByUserLogonID");
         WebExceptionHelper.LogException(ex, null);
         return null;
     }
 }
Exemple #6
0
        public HttpResponseMessage SaveTaskGridFilters([FromBody] UserPreference userPref)
        {
            try
            {
                userPref.preferenceType = "TaskFilter";

                UserServices.UpdateUserPreference(userPref);

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                ex.Data.Add("HTTPReferrer", "JCRAPI/TaskInfo/SaveTaskGridFilters");
                WebExceptionHelper.LogException(ex, null);
                return(null);
            }
        }
Exemple #7
0
        public HttpResponseMessage GetImagesCount(int tracerResponseID)
        {
            //  TracerServices service = new TracerServices();
            try
            {
                var imagesCount = tracerService.GetImagesCount(tracerResponseID);

                return(Request.CreateResponse(HttpStatusCode.OK, imagesCount));
            }
            catch (Exception ex)
            {
                ex.Data.Add("TracerReponseID", tracerResponseID);
                ex.Data.Add("HTTPReferrer", "JCRAPI/Image/GetImagesCount");
                WebExceptionHelper.LogException(ex, null);
                return(null);
            }
        }
Exemple #8
0
        public HttpResponseMessage GetUserSites(int userID)
        {
            try
            {
                //List of Sites where User has either AMP or Tracers Access
                var _result = SiteServices.GetUserSites(userID).Where(m => m.IsAMPAccess == 1 || m.IsTracersAccess == 1);

                return(Request.CreateResponse(HttpStatusCode.OK, _result));
            }
            catch (Exception ex)
            {
                ex.Data.Add("userID", userID);
                ex.Data.Add("HTTPReferrer", "JCRAPI/GetCommonInfo/GetUserSites");
                WebExceptionHelper.LogException(ex, null);
                return(null);
            }
        }
Exemple #9
0
 public HttpResponseMessage GetSecurityQuestionsById(int? questionTypeID)
 {
     PasswordServices service = new PasswordServices();
     string rtnMsg = "You are a new user and have yet to set up your security questions, please contact technical support at 877-223-6866 (Please select option 2) or via email at [email protected].";
     try {
         var questions = service.GetSecurityQuestionsById(questionTypeID);
         if (questions != null) {
             return Request.CreateResponse(HttpStatusCode.OK, questions);
         } else {
             return Request.CreateErrorResponse(HttpStatusCode.NotFound, rtnMsg);
         }
     } catch (Exception ex)  {
         ex.Data.Add("QuestionTypeID", questionTypeID);
         ex.Data.Add("HTTPReferrer", "JCRAPI/PasswordInfo/GetSecurityQuestions");
         WebExceptionHelper.LogException(ex, null);
         return null;
     }
 }
Exemple #10
0
        public HttpResponseMessage GuestLinkAccessed(int userId, Guid guestLinkGuid)
        {
            TracerService tracerService = new TracerService();

            try
            {
                tracerService.InsertGuestLinkAccessed(userId, guestLinkGuid);

                return(Request.CreateResponse(HttpStatusCode.OK, "Success"));
            }
            catch (Exception ex)
            {
                ex.Data.Add("GuestLinkAccessed", guestLinkGuid);
                ex.Data.Add("HTTPReferrer", "JCRAPI/post/guestlinkaccessed");
                WebExceptionHelper.LogException(ex, null);
                return(null);
            }
        }
Exemple #11
0
        public HttpResponseMessage ReAssignTask([FromBody] ReAssignTasks raTasks)
        {
            try
            {
                var lstPreviousTasks = TaskServices.GetTaskDetailsForSendingEmail(raTasks.LstTaskIDs.ToString(), raTasks.SiteID, raTasks.ProgramID, raTasks.UpdatedByUserID);

                TaskServices.ReAssignTask(raTasks);

                Task.Factory.StartNew(() => TaskServices.SendTaskReassignedEmail(raTasks.LstTaskIDs, raTasks.SiteID, raTasks.ProgramID, raTasks.UpdatedByUserID, lstPreviousTasks));

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                ex.Data.Add("HTTPReferrer", "JCRAPI/TaskInfo/ReAssignTask");
                WebExceptionHelper.LogException(ex, null);
                return(Request.CreateResponse(HttpStatusCode.OK, string.Empty));
            }
        }
Exemple #12
0
        public HttpResponseMessage MobileUpdateUserTask([FromBody] UserTask uTask)
        {
            try
            {
                if (uTask != null && !string.IsNullOrEmpty(uTask.LstUsers) && uTask.LstUsers.Length > 0)
                {
                    bool isEditTask = uTask.TaskID > 0;

                    if (isEditTask && uTask.LstUsers.Split(',').Length > 1)
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.ExpectationFailed, "Task can be reassigned to only one individual."));
                    }

                    var _usrList = tracerService.CreateGuestUserByEmailIds(uTask.LstUsers, uTask.SiteID, uTask.UpdatedByUserID);
                    var _ccList  = new List <AssignedUser>();

                    if (!string.IsNullOrEmpty(uTask.CCUserIDs) && uTask.CCUserIDs.Length > 0)
                    {
                        _ccList = tracerService.CreateGuestUserByEmailIds(uTask.CCUserIDs, uTask.SiteID, uTask.UpdatedByUserID);
                    }

                    uTask.LstUsers  = string.Join(",", _usrList.Select(x => x.UserId.ToString()));
                    uTask.CCUserIDs = string.Join(",", _ccList.Select(x => x.UserId.ToString()));

                    if (isEditTask)
                    {
                        uTask.AssignedToUserID = Convert.ToInt32(uTask.LstUsers);
                    }

                    return(UpdateUserTask(uTask));
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.ExpectationFailed, "No valid Task Assignee given."));
                }
            }
            catch (Exception ex)
            {
                ex.Data.Add("HTTPReferrer", "JCRAPI/TaskInfo/MobileUpdateUserTask");
                WebExceptionHelper.LogException(ex, null);
                return(Request.CreateErrorResponse(HttpStatusCode.ExpectationFailed, ex.ToString()));
            }
        }
Exemple #13
0
        public HttpResponseMessage GetGuestUserTracersBySiteProgram(int?userId, int?siteId, int?programId, int?statusId)
        {
            try
            {
                List <ApiGuestUserTracerDetailSelectBySiteProgramReturnModel> rtn = guestUserService.GetGuestUserTracersBySiteProgram(userId, siteId, programId, statusId);

                return(Request.CreateResponse(HttpStatusCode.OK, rtn));
            }
            catch (Exception ex)
            {
                ex.Data.Add("userId", userId);
                ex.Data.Add("siteId", siteId);
                ex.Data.Add("programId", programId);
                ex.Data.Add("statusId", statusId);
                ex.Data.Add("HTTPReferrer", "JCRAPI/GuestUser/GetGuestUserTracersBySiteProgram");
                WebExceptionHelper.LogException(ex, null);
                return(null);
            }
        }
Exemple #14
0
        /// <summary>
        /// To web response.
        /// </summary>
        /// <returns>The http web response</returns>
        public HttpWebResponse ToWebResponse()
        {
            try
            {
                HttpWebRequest request = ToWebRequest();
                return((HttpWebResponse)request.GetResponse());
            }
            catch (WebException webEx)
            {
                OAuthException authException;

                if (WebExceptionHelper.TryWrapException(Context, webEx, out authException, ResponseBodyAction))
                {
                    throw authException;
                }

                throw;
            }
        }
Exemple #15
0
        public HttpResponseMessage CheckUserLoginFirstAfterProductRelease(int eProductId, int userId)
        {
            UserServices service = new UserServices();

            try
            {
                var status = service.CheckUserLoginFirstAfterProductRelease(eProductId, userId);

                return(Request.CreateResponse(HttpStatusCode.OK, new { IsUserFirstLogin = status }));
            }
            catch (Exception ex)
            {
                ex.Data.Add("eProductId", eProductId);
                ex.Data.Add("userId", userId);
                ex.Data.Add("HTTPReferrer", "JCRAPI/UserInfo/CheckUserLoginFirstAfterProductRelease");
                WebExceptionHelper.LogException(ex, null);
                return(null);
            }
        }
Exemple #16
0
        public HttpResponseMessage GetTracerAppVersion()
        {
            string rtn = string.Empty;

            try
            {
                if (ConfigurationManager.AppSettings["TracersMobileAppVersion"] != null)
                {
                    rtn = ConfigurationManager.AppSettings["TracersMobileAppVersion"].ToString();
                }

                return(Request.CreateResponse(HttpStatusCode.OK, rtn));
            }
            catch (Exception ex)
            {
                ex.Data.Add("HTTPReferrer", "JCRAPI/GetCommonInfo/GetTracerAppVersion");
                WebExceptionHelper.LogException(ex, null);
                return(null);
            }
        }
Exemple #17
0
        public HttpResponseMessage UpdateSiteEmailNotificationSettings([FromBody] SiteEmailNotificationSetting siteEmailNotificationSetting)
        {
            try
            {
                TaskServices.UpdateSiteEmailNotificationSettings(siteEmailNotificationSetting.SiteID, siteEmailNotificationSetting.SendEmailOnTaskCreation, siteEmailNotificationSetting.SendEmailBeforeTaskDue, siteEmailNotificationSetting.DaysBeforeTaskDue, siteEmailNotificationSetting.SendEmailsAfterTaskDue, siteEmailNotificationSetting.DaysAfterTaskDue
                                                                 , siteEmailNotificationSetting.SendRemainderEmailAfterTaskDue, siteEmailNotificationSetting.SendTaskReportToCC, siteEmailNotificationSetting.TaskReportToCCScheduleTypeID, siteEmailNotificationSetting.SendTaskReportToUsers, siteEmailNotificationSetting.TaskReportToUsersScheduleTypeID, siteEmailNotificationSetting.TaskReportRecipients
                                                                 , siteEmailNotificationSetting.SendEmailOnAssigningEP, siteEmailNotificationSetting.TaskDueRecipientType, siteEmailNotificationSetting.UpdatedBy);

                Task.Factory.StartNew(() => TaskServices.DisableTaskNotificationScheduleType(DisableTaskNotificationScheduleType.EmailSetting, siteEmailNotificationSetting.SiteID, siteEmailNotificationSetting.UpdatedBy));

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                ex.Data.Add("siteID", siteEmailNotificationSetting.SiteID);
                ex.Data.Add("HTTPReferrer", "JCRAPI/TaskInfo/UpdateSiteEmailNotificationSettings");
                WebExceptionHelper.LogException(ex, null);
                return(null);
            }
        }
Exemple #18
0
        public HttpResponseMessage GetSelectProgramsBySite(int?userId, int?siteId, DateTime?standardEffBeginDate, int?productId)
        {
            SiteServices siteService = new SiteServices();

            try
            {
                var programs = siteService.GetSelectProgramsBySite(userId, siteId, standardEffBeginDate, productId);
                if (programs != null && programs.Count > 0)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, programs));
                }
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "No program found for this id"));
            }
            catch (Exception ex)
            {
                ex.Data.Add("SiteID", siteId);
                ex.Data.Add("HTTPReferrer", "JCRAPI/GetCommonInfo/GetSelectProgramsBySite");
                WebExceptionHelper.LogException(ex, null);
                return(null);
            }
        }
Exemple #19
0
        public HttpResponseMessage GetCMSTaskListByCMSStandardID(string standardEffDate, int siteId, int programId, int cmsStandardId)
        {
            try
            {
                var taskList = TaskServices.GetCMSTaskListByCMSStandardID(standardEffDate, siteId, programId, cmsStandardId);

                if (taskList != null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, taskList));
                }

                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "No Tasks Found"));
            }
            catch (Exception ex)
            {
                ex.Data.Add("SiteID", siteId);
                ex.Data.Add("HTTPReferrer", "JCRAPI/TaskInfo/GetCMSTaskListByCMSStandardID");
                WebExceptionHelper.LogException(ex, null);
                return(null);
            }
        }
Exemple #20
0
        public HttpResponseMessage GetTaskFollowUpRemainderSettings(int siteId)
        {
            try
            {
                var taskfollowupRemainderSettings = TaskServices.GetTaskFollowUpRemainderSettings(siteId);

                if (taskfollowupRemainderSettings != null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, taskfollowupRemainderSettings));
                }

                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "No data found"));
            }
            catch (Exception ex)
            {
                ex.Data.Add("siteId", siteId);
                ex.Data.Add("HTTPReferrer", "JCRAPI/TaskInfo/GetTaskFollowUpRemainderSettings");
                WebExceptionHelper.LogException(ex, null);
                return(null);
            }
        }
Exemple #21
0
        public HttpResponseMessage UpdateUserPassword(int userId, string password, bool?isWithRules)
        {
            try
            {
                UserServices service = new UserServices();


                int    _resut;
                string rtnMessage;
                if (isWithRules != null && isWithRules == true)
                {
                    _resut = service.UpdateUserPasswordWithRestrictionRules(userId, password, out rtnMessage);
                }
                else
                {
                    _resut = service.UpdateUserPassword(userId, password, out rtnMessage);
                }


                if (_resut == 1)
                {
                    var response = Request.CreateResponse(HttpStatusCode.OK, "Update Successed");
                    response.Headers.Add("message", rtnMessage);
                    return(response);
                }
                else
                {
                    var response = Request.CreateErrorResponse(HttpStatusCode.BadRequest, rtnMessage);
                    //  response.Headers.Add("message", rtnMessage);
                    return(response);
                }
            }
            catch (Exception ex)
            {
                ex.Data.Add("userId", userId);
                ex.Data.Add("HTTPReferrer", "JCRAPI/UserInfo/AddUserSecurityAttribute");
                WebExceptionHelper.LogException(ex, null);
                return(null);
            }
        }
Exemple #22
0
        public IEnumerable InvokesRetryPolicyExceptions()
        {
            yield return(new object[]
            {
                new Exception("General Exception should be retried"),
                true
            });

            yield return(new object[]
            {
                WebExceptionHelper.CreateWebExceptionWithStatusCode(HttpStatusCode.InternalServerError),
                // retry on a 500
                true
            });

            yield return(new object[]
            {
                WebExceptionHelper.CreateWebExceptionWithStatusCode(HttpStatusCode.NotFound),
                // do not retry on 404
                false
            });
        }
Exemple #23
0
        public async Task <HttpResponseMessage> TempImageClean(int tracerCustomID, int userID)
        {
            try
            {
                //  TracerServices service = new TracerServices();

                //GetTempImagestoClean
                List <ApiGetTracerImagesTempReturnModel> _result = tracerService.GetTempImagestoClean(tracerCustomID, userID);
                if (_result.Count > 0)
                {
                    //Azure settings
                    var        container = UploadImage.azureContainer();
                    ICloudBlob _blockBlob;
                    //delete blob from container
                    foreach (var tempImage in _result)
                    {
                        //delete Actual Image
                        _blockBlob = await container.GetBlobReferenceFromServerAsync("Actual/" + tempImage.SiteID + "/" + tempImage.ProgramID + "/" + tempImage.TracerCustomID + "/" + tempImage.ImageName);

                        _blockBlob.Delete();
                        //delete Thumb Image
                        _blockBlob = await container.GetBlobReferenceFromServerAsync("Thumb/" + tempImage.SiteID + "/" + tempImage.ProgramID + "/" + tempImage.TracerCustomID + "/" + tempImage.ImageName);

                        _blockBlob.Delete();
                    }

                    tracerService.DeleteImagesTemp(tracerCustomID, userID);
                }
                return(Request.CreateResponse(HttpStatusCode.OK, "Files Deleted"));
            }
            catch (Exception ex)
            {
                ex.Data.Add("tracerCustomId", tracerCustomID);
                ex.Data.Add("HTTPReferrer", "JCRAPI/Image/Delete");
                WebExceptionHelper.LogException(ex, null);
                return(null);
            }
        }
Exemple #24
0
        public HttpResponseMessage InsertGuestUserEULA([FromBody] UserAttribute Attribute)
        {
            try
            {
                int          attributeTypeId_EULA = 304;
                UserServices service = new UserServices();
                if (Attribute.AttributeActivationDate == null)
                {
                    Attribute.AttributeActivationDate = DateTime.Now;
                }
                if (Attribute.AttributeExpirationDate == null)
                {
                    Attribute.AttributeExpirationDate = DateTime.Now;
                }

                ApiAddUserSecurityAttributeReturnModel _result = new ApiAddUserSecurityAttributeReturnModel();
                //This method is for insert Guest User EULAT Only, attributetype code is hardcoded to 304
                _result = service.AddUserSecurityAttribute(Attribute.UserId, attributeTypeId_EULA, Attribute.AttributeValue, Attribute.AttributeActivationDate, Attribute.AttributeExpirationDate);

                if (_result != null)
                {
                    var response = Request.CreateResponse(HttpStatusCode.OK, "Authorized");

                    return(Request.CreateResponse(HttpStatusCode.OK, _result));
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Add User Attribute Failed"));
                }
            }
            catch (Exception ex)
            {
                ex.Data.Add("userId", Attribute.UserId);
                ex.Data.Add("HTTPReferrer", "JCRAPI/UserInfo/AddUserSecurityAttribute");
                WebExceptionHelper.LogException(ex, null);
                return(null);
            }
        }
Exemple #25
0
        public HttpResponseMessage GetEPsByStandard(int userId, int productType, int siteId, int programId, int standardTextId, string standardEffBeginDate, int serviceProfileTypeId, int certificationItemId)
        {
            try
            {
                var EPsByStandard = TaskServices.GetEPsByStandard(userId, productType, siteId, programId, standardTextId, standardEffBeginDate, serviceProfileTypeId, certificationItemId);

                var _result = EPsByStandard.Select(m => new
                {
                    EPTextID        = m.EPTextID,
                    EPText          = m.EPText,
                    EPTextShortened = m.EPText.Length > 150 ? m.EPText.Substring(0, 150) + "..." : m.EPText,
                    SortOrder       = m.SortOrder
                });

                return(Request.CreateResponse(HttpStatusCode.OK, _result));
            }
            catch (Exception ex)
            {
                ex.Data.Add("HTTPReferrer", "JCRAPI/TaskInfo/GetEPsByStandard");
                WebExceptionHelper.LogException(ex, null);
                return(Request.CreateResponse(HttpStatusCode.OK, string.Empty));
            }
        }
Exemple #26
0
        public HttpResponseMessage AddAppEventLog(int programId, int siteId, int actionTypeId, int userId, int productId)
        {
            try
            {
                int _result;

                //Update AppEventLog table
                _result = trackingService.AddAppEventLog(programId, siteId, actionTypeId, userId);

                if (_result != 1)
                {
                    //Update AppEventLogDetail table
                    _result = trackingService.AddAppEventLogDetail(programId, siteId, actionTypeId, userId, productId);
                    if (_result != 1)
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, "Event log updated"));
                    }
                    else
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Event log update failed"));
                    }
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Event log update failed"));
                }
            }
            catch (Exception ex)
            {
                ex.Data.Add("SiteId", siteId);
                ex.Data.Add("UserId", userId);
                ex.Data.Add("HTTPReferrer", "JCRAPI/TrackingInfo/AddAppEventLog");
                WebExceptionHelper.LogException(ex, null);
                return(null);
            }
        }
Exemple #27
0
        public HttpResponseMessage GetElementsByTag(int?programId, string tagCode)
        {
            try
            {
                var COPList = TaskServices.GetElementsByCopId(programId, tagCode);

                var _result = COPList.Select(m => new
                {
                    CmsStandardID           = m.CmsStandardID,
                    TagCode                 = m.TagCode,
                    JcrElementText          = m.JcrElementText.Replace("<br/>", ""),
                    JcrElementTextShortened = m.JcrElementText.Length > 150 ? m.JcrElementText.Substring(0, 150) + "..." : m.JcrElementText,
                    ElementSortOrder        = m.ElementSortOrder
                });

                return(Request.CreateResponse(HttpStatusCode.OK, _result));
            }
            catch (Exception ex)
            {
                ex.Data.Add("HTTPReferrer", "JCRAPI/TaskInfo/GetElementsByTag");
                WebExceptionHelper.LogException(ex, null);
                return(Request.CreateResponse(HttpStatusCode.OK, string.Empty));
            }
        }
Exemple #28
0
        public HttpResponseMessage VerifySecurityAnswer([FromBody] List <SecurityQuestionAnswer> answerList, int userId)
        {
            UserServices service = new UserServices();
            bool         rtn;

            try
            {
                rtn = service.VerifySecurityQuestionAnswer(answerList, userId);
                if (!rtn)
                {
                    var response = Request.CreateErrorResponse(HttpStatusCode.BadRequest, "The answers to your security questions do not match our records.");
                    response.Headers.Add("message", "The answers to your security questions do not match our records.");

                    return(response);
                }

                else
                {
                    TokenServices tokenService = new TokenServices();
                    var           token        = tokenService.GenerateToken(userId);
                    var           response     = Request.CreateResponse(HttpStatusCode.OK, "Authorized");
                    response.Headers.Add("Token", token.AuthToken);
                    response.Headers.Add("UserId", userId.ToString());
                    response.Headers.Add("TokenExpiry", ConfigurationManager.AppSettings["AuthTokenExpiry"]);
                    response.Headers.Add("Access-Control-Expose-Headers", "Token,TokenExpiry");
                    return(response);
                }
            }
            catch (Exception ex)
            {
                ex.Data.Add("userId", userId);
                ex.Data.Add("HTTPReferrer", "JCRAPI/UserInfo/GetSQuestions");
                WebExceptionHelper.LogException(ex, null);
                return(null);
            }
        }
Exemple #29
0
        public HttpResponseMessage GetUserRoleBySite(int userId, int siteId)
        {
            UserServices service = new UserServices();

            try
            {
                ApiGetUserRoleBySiteReturnModel rtn = service.GetUserRoleBySite(userId, siteId);
                if (rtn != null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, rtn));
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "No Role find for this User"));
                }
            }
            catch (Exception ex)
            {
                ex.Data.Add("userId", userId);
                ex.Data.Add("HTTPReferrer", "JCRAPI/UserInfo/GetUserRoleBySite");
                WebExceptionHelper.LogException(ex, null);
                return(null);
            }
        }
Exemple #30
0
        public HttpResponseMessage GetUserByLogonId(string logonId)
        {
            UserServices service = new UserServices();

            try
            {
                ApiSelectUserByUserLogonIdReturnModel user = service.GetUserByLogonId(logonId);
                if (user != null)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, user));
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "No user found for this Id"));
                }
            }
            catch (Exception ex)
            {
                ex.Data.Add("logonId", logonId);
                ex.Data.Add("HTTPReferrer", "JCRAPI/UserInfo/GetUserByLogonId");
                WebExceptionHelper.LogException(ex, null);
                return(null);
            }
        }