Пример #1
0
        public GenericAjaxResponse <List <UserSecurityOption> > GetSecurityQuestionsForUser(string username)
        {
            GenericAjaxResponse <List <UserSecurityOption> > response = new GenericAjaxResponse <List <UserSecurityOption> >();

            try
            {
                var request = new RestRequest("api/Userinfo/GetQuestionsForUser", Method.POST);
                request.AddQueryParameter("username", username);
                var restResponse = _restClient.Execute <GenericResponse <List <AHP.Core.DTO.UserSecurityOption> > >(request);
                if (restResponse.ResponseStatus == ResponseStatus.Completed && restResponse.Data != null)
                {
                    response.Success = restResponse.Data.Success;
                    response.Data    = restResponse.Data.Data;
                    response.Errors  = restResponse.Data.Errors;
                    return(response);
                }
                else
                {
                    response.Success = false;
                    return(response);
                }
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Errors.Add("An error occurred. Please try again.");
            }
            return(response);
        }
Пример #2
0
        public ActionResult GetUsersForView(string viewId)
        {
            GenericAjaxResponse <List <Web.ViewModel.TableauViewUserAssociation> > webResponse = new GenericAjaxResponse <List <Web.ViewModel.TableauViewUserAssociation> >();

            try
            {
                if (string.IsNullOrEmpty(viewId))
                {
                    webResponse.Errors.Add("View id provided is empty");
                    webResponse.Success = false;
                    return(Json(webResponse));
                }
                GenericAjaxResponse <List <Core.DTO.TableauViewUserAssociation> > apiResponse = _restClient.ListViewAssociations(viewId);
                webResponse.Errors  = apiResponse.Errors;
                webResponse.Success = apiResponse.Success;
                if (apiResponse.Data != null)
                {
                    webResponse.Data = apiResponse.Data.Select(view => new Web.ViewModel.TableauViewUserAssociation()
                    {
                        Selected = view.Selected,
                        Username = view.Username,
                        UserType = view.UserType,
                        ViewId   = view.ViewId
                    }).ToList();
                }
            }
            catch (Exception ex)
            {
                webResponse.Success = false;
                webResponse.Errors.Add("Could not process the request.");
                _logger.Error("Error occurred getting list of all users for view", ex);
            }
            return(Json(webResponse));
        }
Пример #3
0
        public ActionResult AddTableauView(AHP.Web.ViewModel.TableauWorkbookViewModel tableauView)
        {
            GenericAjaxResponse <bool> response = new GenericAjaxResponse <bool>();

            try
            {
                if (ModelState.IsValid)
                {
                    AHP.Core.DTO.TableauViewInfo dto = new Core.DTO.TableauViewInfo();
                    dto.Description = string.IsNullOrEmpty(tableauView.Description) ? string.Empty : tableauView.Description.Substring(0, Math.Min(400, tableauView.Description.Length));
                    dto.Disabled    = string.IsNullOrEmpty(tableauView.Disabled) ? "N" : tableauView.Disabled;
                    dto.IsDashboard = string.IsNullOrEmpty(tableauView.IsDashboard) ? "N" : tableauView.IsDashboard;
                    dto.ViewId      = tableauView.ViewId;
                    dto.ViewName    = tableauView.ViewName;
                    dto.ViewUrl     = tableauView.ViewUrl;
                    response        = _restClient.AddTableauView(dto);
                }
                else
                {
                    foreach (var modelKey in ModelState.Keys)
                    {
                        response.Errors.AddRange(ModelState[modelKey].Errors.Select(err => err.ErrorMessage));
                    }
                    response.Success = response.Errors.Count == 0;
                }
            }
            catch (Exception ex)
            {
                response.Success = response.Data = false;
                response.Errors.Add("Could not process your request. Please try again.");
                _logger.Error("Add tableau view ended up with an error", ex);
            }
            return(Json(response));
        }
Пример #4
0
        public ActionResult UpdateTableauUserInfo(string viewId, List <AHP.Web.ViewModel.TableauViewUserAssociation> userInfo)
        {
            GenericAjaxResponse <bool> response = new GenericAjaxResponse <bool>();

            try
            {
                List <Core.DTO.TableauViewUserAssociation> usrVwAssoc = new List <Core.DTO.TableauViewUserAssociation>();
                if (userInfo != null && userInfo.Count > 0)
                {
                    //add only selected or checked users only
                    usrVwAssoc.AddRange(userInfo.Where(usrInf => usrInf.Selected).Select(usrInf => new Core.DTO.TableauViewUserAssociation()
                    {
                        Username = usrInf.Username,
                        UserType = usrInf.UserType,
                        ViewId   = viewId
                    }));
                }
                response = _restClient.UpdateTableauUserAssociation(viewId, usrVwAssoc);
            }
            catch (Exception ex)
            {
                response.Success = response.Data = false;
                response.Errors.Add("Could not process your request");
                _logger.Error("Error occurred updating tableau view user association", ex);
            }
            return(Json(response));
        }
Пример #5
0
        public ActionResult Userdetail(string username)
        {
            GenericAjaxResponse <AHP.Core.DTO.ExternalUserInfo> response = new GenericAjaxResponse <Core.DTO.ExternalUserInfo>();

            try
            {
                if (string.IsNullOrEmpty(username))
                {
                    response.Success = false;
                    response.Errors.Add("Please provider a username");
                    return(Json(response));
                }
                response = _restClient.GetUserDetails(username);
                if (response == null)
                {
                    response         = new GenericAjaxResponse <Core.DTO.ExternalUserInfo>();
                    response.Success = false;
                    response.Errors.Add("An error occurred. Please try again.");
                }
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Errors.Add("Error occurred.");
                _logger.Error("Error occurred getting user details", ex);
            }
            return(Json(response));
        }
Пример #6
0
        public GenericAjaxResponse <bool> ResetPassword(string username, List <UserSecurityOption> securityQuestionAnswers)
        {
            GenericAjaxResponse <bool> response       = new GenericAjaxResponse <bool>();
            RestRequest restRequest                   = new RestRequest("api/Userinfo/ValidateQuestions", Method.POST);
            UpdateSecurityQuestionsRequest apiRequest = new UpdateSecurityQuestionsRequest()
            {
                Username          = username,
                SecurityQuestions = securityQuestionAnswers
            };

            restRequest.AddJsonBody(apiRequest);
            IRestResponse <GenericResponse <bool> > restResponse = _restClient.Execute <GenericResponse <bool> >(restRequest);

            if (restResponse.StatusCode == System.Net.HttpStatusCode.OK)
            {
                if (restResponse.Data != null)
                {
                    response.Success = restResponse.Data.Success;
                    response.Data    = restResponse.Data.Data;
                    response.Errors  = restResponse.Data.Errors;
                }
                else
                {
                    response.Success = false;
                    response.Errors.Add("Could not reset password. Please try again.");
                }
            }
            return(response);
        }
Пример #7
0
        public ActionResult ActivateUser(AHP.Core.DTO.ExternalUserInfo userInfo)
        {
            GenericAjaxResponse <bool> response = new GenericAjaxResponse <bool>();

            try
            {
                if (string.IsNullOrEmpty(userInfo.Username))
                {
                    response.Success = false;
                    response.Errors.Add("Username is required");
                    return(Json(response));
                }

                if (string.IsNullOrEmpty(userInfo.Email))
                {
                    response.Success = false;
                    response.Errors.Add("Email is required");
                    return(Json(response));
                }

                response = _restClient.ActivateUser(userInfo.Username, userInfo.Email);
                if (response == null)
                {
                    response         = new GenericAjaxResponse <bool>();
                    response.Success = false;
                    response.Errors.Add("An error occurred. Please try again.");
                }
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Errors.Add("Error occurred. Please try again");
            }
            return(Json(response));
        }
Пример #8
0
        public GenericAjaxResponse <string> SignIn(string username)
        {
            GenericAjaxResponse <string> apiResponse = new GenericAjaxResponse <string>()
            {
                Success = false
            };
            string      signOnUrl     = string.Format("/trusted");
            RestRequest signInRequest = new RestRequest(signOnUrl);

            signInRequest.Method = Method.POST;
            signInRequest.AddHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
            signInRequest.AddParameter("username", username);
            signInRequest.AddParameter("target_site", System.Configuration.ConfigurationManager.AppSettings["tableauSite"]);
            IRestResponse signOnResponse = _tableauRestClient.Execute(signInRequest);

            if (signOnResponse.StatusCode == System.Net.HttpStatusCode.OK)
            {
                //AUTH Ticket seems to be always a 49 characters
                if (signOnResponse.Content != "-1" && signOnResponse.ContentType == "*; charset=UTF-8" && signOnResponse.ContentLength == 49)
                {
                    apiResponse.Data    = signOnResponse.Content;
                    apiResponse.Success = true;
                }
                else
                {
                    apiResponse.Success = false;
                    apiResponse.Data    = string.Empty;
                }
            }
            return(apiResponse);
        }
Пример #9
0
        public GenericAjaxResponse <bool> ChangePassword(string username, string oldPassword, string newPassword)
        {
            GenericAjaxResponse <bool> response = new GenericAjaxResponse <bool>();

            try
            {
                RestRequest restRequest = new RestRequest("api/Userinfo/ChangePassword", Method.POST);
                restRequest.AddQueryParameter("username", username);
                restRequest.AddQueryParameter("oldPassword", oldPassword);
                restRequest.AddQueryParameter("newPassword", newPassword);
                IRestResponse <GenericResponse <bool> > restResponse = _restClient.Execute <GenericResponse <bool> >(restRequest);
                if (restResponse.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    response.Success = restResponse.Data.Success;
                    response.Data    = restResponse.Data.Data;
                    response.Errors  = restResponse.Data.Errors;
                }
            }
            catch (Exception ex)
            {
                response.Errors.Add("Error occurred updating your password. Please try again");
                response.Success = false;
                response.Data    = false;
            }
            return(response);
        }
Пример #10
0
        public ActionResult CreateUser(ViewModel.UserinfoViewModel userInfo)
        {
            GenericAjaxResponse <bool> response = new GenericAjaxResponse <bool>();

            try
            {
                if (ModelState.IsValid)
                {
                    if (!userInfo.Role.Equals("admin", StringComparison.OrdinalIgnoreCase) && !userInfo.Role.Equals("user", StringComparison.OrdinalIgnoreCase))
                    {
                        response.Errors.Add("Role can be only admin or user");
                        response.Success = false;
                        return(Json(response));
                    }

                    AHP.Core.DTO.ExternalUserInfo externalUserAccount = new Core.DTO.ExternalUserInfo();
                    //Only subset of properties are to be filled. Since others are maintained internally
                    externalUserAccount.Username   = userInfo.Username;
                    externalUserAccount.Email      = userInfo.Email;
                    externalUserAccount.Firstname  = userInfo.Firstname;
                    externalUserAccount.Lastname   = userInfo.Lastname;
                    externalUserAccount.Role       = userInfo.Role;
                    externalUserAccount.SupplierId = string.Join(",", userInfo.SupplierId.Split(',').Distinct());
                    externalUserAccount.BirthMonth = short.Parse(userInfo.BirthMonth);
                    externalUserAccount.BirthYear  = short.Parse(userInfo.BirthYear);
                    externalUserAccount.ZipCode    = userInfo.ZipCode;
                    externalUserAccount.Company    = userInfo.Company;
                    externalUserAccount.CreatedBy  = Identity.UserName;

                    response = _restClient.CreateUser(externalUserAccount);
                    if (response == null)
                    {
                        response         = new GenericAjaxResponse <bool>();
                        response.Success = false;
                        response.Errors.Add("An error occurred. Please try again.");
                    }
                    else
                    {
                        response.Success = response.Data;
                    }
                }
                else
                {
                    foreach (var modelKey in ModelState.Keys)
                    {
                        response.Errors.AddRange(ModelState[modelKey].Errors.Select(err => err.ErrorMessage));
                    }
                    response.Success = response.Errors.Count == 0;
                }
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Errors.Add("Error occurred getting users. Please try again");
                _logger.Info("Could not retrieve users from database. Error " + ex.Message);
            }
            return(Json(response));
        }
Пример #11
0
        public ActionResult ValidateUsername(ViewModel.AccountRecoveryInfoViewModel accountInfo)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    ModelState.AddModelError("Username", "Username is required");
                    _logger.Info("User submitted password reset form. But username does not exist in form value. Showing validation message.");
                    return(View("~/Views/AccountRecovery/ResetPassword.cshtml", accountInfo));
                }

                //Check user account disabled or not
                GenericAjaxResponse <AHP.Core.DTO.ExternalUserInfo> userResponse = _restClient.GetUserDetails(accountInfo.Username);
                if (!userResponse.Success || userResponse.Data == null)
                {
                    ModelState.AddModelError("Username", "Account information does not exist");
                    return(View("~/Views/AccountRecovery/ResetPassword.cshtml", accountInfo));
                }

                if (!userResponse.Data.IsActive)
                {
                    ModelState.AddModelError("Username", "Your account has been disabled. Please contact your account manager.");
                    return(View("~/Views/AccountRecovery/ResetPassword.cshtml", accountInfo));
                }

                //Get security questions for the user.
                GenericAjaxResponse <List <AHP.Core.DTO.UserSecurityOption> > apiResponse = _restClient.GetSecurityQuestionsForUser(accountInfo.Username);

                //only two questions need to be present and user should also be present
                if (apiResponse.Success && apiResponse.Data != null && apiResponse.Data.Count == 3)
                {
                    ViewModel.UserQuestionsViewmodel usrQuestionInfo = new ViewModel.UserQuestionsViewmodel()
                    {
                        SecurityQuestions = new List <string>()
                    };

                    //Pre fill primary and secondary questions that the user had selected
                    usrQuestionInfo.PrimarySelectedQuestion   = apiResponse.Data[0].Question;
                    usrQuestionInfo.SecondarySelectedQuestion = apiResponse.Data[1].Question;
                    usrQuestionInfo.ThirdSelectedQuestion     = apiResponse.Data[2].Question;
                    ViewBag.Username = accountInfo.Username;

                    _logger.Info("User details exists. Redirecting to answer security question page.");
                    return(View("~/Views/AccountRecovery/AnswerSecurityQuestions.cshtml", usrQuestionInfo));
                }
                else
                {
                    ModelState.AddModelError(string.Empty, "Account information does not exist or you haven't setup your security questions in the system yet.");
                    return(View("~/Views/AccountRecovery/ResetPassword.cshtml", accountInfo));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, "We are sorry. Could not process your request at this time.");
                _logger.Error("Error occurred validating username", ex);
                return(View("~/Views/AccountRecovery/ResetPassword.cshtml", accountInfo));
            }
        }
Пример #12
0
        public GenericAjaxResponse <bool> SignOut(string ticket)
        {
            string signOutUrl = string.Format("/api/{0}/auth/signout", _tableauServerInfo.ApiVersion);
            GenericAjaxResponse <bool> apiResponse = new GenericAjaxResponse <bool>();
            RestRequest signOutRequest             = new RestRequest(signOutUrl);

            signOutRequest.Method = Method.POST;
            signOutRequest.AddHeader("X-Tableau-Auth", ticket);
            IRestResponse signOutResponse = _tableauRestClient.Execute(signOutRequest);

            return(apiResponse);
        }
Пример #13
0
        public GenericAjaxResponse <List <TableauWorkbookView> > ViewsForWorkbook(string siteId, string workbookId, string ticket)
        {
            //does not work
            string viewsForWorkbookUrl = string.Format("/api/{0}/sites/{1}/workbooks/{2}/views", _tableauServerInfo.ApiVersion, siteId, workbookId);
            GenericAjaxResponse <List <TableauWorkbookView> > apiResponse = new GenericAjaxResponse <List <TableauWorkbookView> >();
            RestRequest viewsForWorkbookRequest = new RestRequest(viewsForWorkbookUrl);

            viewsForWorkbookRequest.AddHeader("X-Tableau-Auth", ticket);
            IRestResponse viewsForWorkbookResponse = _tableauRestClient.Execute(viewsForWorkbookRequest);

            return(apiResponse);
        }
Пример #14
0
        public GenericAjaxResponse <List <TableauWorkbook> > WorkbooksForUser(string siteId, string userId, string ticket)
        {
            //does not work
            string workbooksForUserUrl = string.Format("/api/{0}/sites/{1}/users/{2}/workbooks", _tableauServerInfo.ApiVersion, siteId, userId);
            GenericAjaxResponse <List <TableauWorkbook> > apiResponse = new GenericAjaxResponse <List <TableauWorkbook> >();
            RestRequest workbookForUserRequest = new RestRequest(workbooksForUserUrl);

            workbookForUserRequest.AddHeader("X-Tableau-Auth", ticket);
            IRestResponse workbooksForUserResponse = _tableauRestClient.Execute(workbookForUserRequest);

            return(apiResponse);
        }
Пример #15
0
        public GenericAjaxResponse <List <TableauSite> > SitesForUser(string ticket)
        {
            //does not work
            string sitesForUserUrl = string.Format("api/{0}/sites", _tableauServerInfo.ApiVersion);
            GenericAjaxResponse <List <TableauSite> > apiResponse = new GenericAjaxResponse <List <TableauSite> >();
            RestRequest sitesForUserRequest = new RestRequest(sitesForUserUrl);

            sitesForUserRequest.AddHeader("X-Tableau-Auth", ticket);
            IRestResponse sitesForUserResponse = _tableauRestClient.Execute(sitesForUserRequest);

            return(apiResponse);
        }
Пример #16
0
        public ActionResult Home()
        {
            ReportViewModel reportVM = new ReportViewModel();

            try
            {
                _logMessage.Append("Getting reports list using sap token Customer Controller Home Method.");
                ViewBag.IsInternalUser = Identity.IsInternalUser;

                if (Identity != null && !string.IsNullOrEmpty(Identity.SapToken))
                {
                    reportVM.Category = _restClient.GetReportList(Identity.SapToken);
                    _logMessage.Append("Identity and Sap token are present. Sap Token passed is " + Identity.SapToken + ".");
                }
                else
                {
                    _logMessage.Append("Identity or Sap Token is missing");
                }

                if (Identity != null)
                {
                    //get all tableau views
                    GenericAjaxResponse <List <AHP.Core.DTO.TableauViewInfo> > apiResponse = _restClient.GetUsersViews(Identity.UserName, Identity.IsInternalUser ? "INTERNAL" : "EXTERNAL");
                    if (apiResponse.Success && apiResponse.Data != null)
                    {
                        List <Web.ViewModel.TableauWorkbookViewModel> uiResponse = apiResponse.Data.Select(dto => new Web.ViewModel.TableauWorkbookViewModel()
                        {
                            Description      = dto.Description,
                            ShortDescription = dto.Description.Substring(0, Math.Min(136, dto.Description.Length)),
                            Disabled         = dto.Disabled,
                            IsDashboard      = dto.IsDashboard,
                            ShortName        = dto.ViewName.Substring(0, Math.Min(51, dto.ViewName.Length)),
                            ViewId           = dto.ViewId,
                            ViewName         = dto.ViewName,
                            ViewUrl          = dto.ViewUrl
                        }).ToList();

                        ViewBag.TableauViews = uiResponse.
                                               Where(vw => vw.IsDashboard.Equals("N", StringComparison.OrdinalIgnoreCase) && vw.Disabled.Equals("N", StringComparison.OrdinalIgnoreCase)).
                                               ToList();
                        ViewBag.TableauDashboards = uiResponse.Where(vw => vw.IsDashboard.Equals("Y", StringComparison.OrdinalIgnoreCase) && vw.Disabled.Equals("N", StringComparison.OrdinalIgnoreCase)).ToList();
                    }
                }
            }
            catch (Exception ex)
            {
                _logMessage.Append("An error occurred getting reports. Exception information " + ex.Message);
                Elmah.ErrorLog.GetDefault(null).Log(new Elmah.Error(ex));
            }
            _logger.Info(_logMessage.ToString());
            return(View(reportVM));
        }
Пример #17
0
        public ActionResult ChangePassword(ViewModel.PasswordResetViewModel updatePwdInfo)
        {
            GenericAjaxResponse <bool> changePwdResponse = new GenericAjaxResponse <bool>();

            _logMessages.AppendFormat("Password change requested for user {0}.", Identity.UserName);
            try
            {
                if (ModelState.IsValid)
                {
                    _logMessages.Append("Model validation successfull. Sending password details to service to change password.");
                    changePwdResponse = _restClient.ChangePassword(Identity.UserName, updatePwdInfo.OldPassword, updatePwdInfo.NewPassword);
                }
            }
            catch (Exception ex)
            {
                _logMessages.AppendFormat("Change password ended with error. Exception message is {0}", ex.Message);
            }
            _logger.Info(_logMessages.ToString());
            if (changePwdResponse.Success)
            {
                //Update the claim value first
                Dictionary <string, string> claimValues = new Dictionary <string, string>();
                claimValues.Add(AHP.Core.ClaimTypes.MustChangePassword, bool.FalseString);
                claimValues.Add(AHP.Core.ClaimTypes.PasswordExpired, bool.FalseString);
                _authManager.UpdateClaim(Request, claimValues);
                if (Identity.MustSelectSecurityQuestions)
                {
                    //send to select security questions
                    return(RedirectToAction("SelectQuestions", "SetupUser"));
                }
                else
                {
                    //redirect to customer home page
                    return(RedirectToAction("Home", "Customer"));
                }
            }
            else
            {
                //send back view with the error
                foreach (string errMsg in changePwdResponse.Errors)
                {
                    ModelState.AddModelError(string.Empty, errMsg);
                }
                if (updatePwdInfo != null)
                {
                    updatePwdInfo.NewPassword = updatePwdInfo.OldPassword = updatePwdInfo.ConfirmPassword = string.Empty;
                }
                return(View(updatePwdInfo));
            }
        }
Пример #18
0
        public ActionResult GetInternalUsers()
        {
            GenericAjaxResponse <List <AHP.Core.DTO.InternalUserInfo> > apiResponse = new GenericAjaxResponse <List <AHP.Core.DTO.InternalUserInfo> >();

            try
            {
                apiResponse = _restClient.GetInternalUsers();
            }
            catch (Exception ex)
            {
                _logger.Info("Error occured getting internal user list", ex);
                apiResponse.Success = false;
                apiResponse.Errors.Add("Could not process your request");
            }
            return(Json(apiResponse));
        }
Пример #19
0
        public ActionResult ListTableauViews()
        {
            GenericAjaxResponse <List <AHP.Core.DTO.TableauViewInfo> > apiResponse = new GenericAjaxResponse <List <AHP.Core.DTO.TableauViewInfo> >();

            try
            {
                apiResponse = _restClient.GetTableauViews();
            }
            catch (Exception ex)
            {
                _logger.Info("Error occured getting tableau workbook views list", ex);
                apiResponse.Success = false;
                apiResponse.Errors.Add("Could not process your request");
            }
            return(Json(apiResponse));
        }
Пример #20
0
        public GenericAjaxResponse <string> SignIn(string username, string password)
        {
            string signOnUrl = string.Format("/api/{0}/auth/signin", _tableauServerInfo.ApiVersion);
            GenericAjaxResponse <string> apiResponse = new GenericAjaxResponse <string>();
            RestRequest signInRequest = new RestRequest(signOnUrl);

            signInRequest.AddXmlBody(string.Format("<tsRequest><credentials name='{0}' password='******'><site contentUrl='{2}'/></credentials></tsRequest>", username, password, System.Configuration.ConfigurationManager.AppSettings["tableauSite"]));
            signInRequest.Method = Method.POST;
            IRestResponse signOnResponse = _tableauRestClient.Execute(signInRequest);

            if (signOnResponse.StatusCode == System.Net.HttpStatusCode.OK)
            {
                return(apiResponse);
            }
            return(apiResponse);
        }
Пример #21
0
        public GenericAjaxResponse <bool> RemoveSecurityQuestions(string username)
        {
            GenericAjaxResponse <bool> response = new GenericAjaxResponse <bool>();
            RestRequest restRequest             = new RestRequest("api/Userinfo/RemoveQuestions", Method.POST);

            restRequest.AddParameter("username", username);
            IRestResponse <GenericResponse <bool> > restResponse = _restClient.Execute <GenericResponse <bool> >(restRequest);

            if (restResponse.StatusCode == System.Net.HttpStatusCode.OK)
            {
                response.Success = restResponse.Data.Success;
                response.Data    = restResponse.Data.Data;
                response.Errors  = restResponse.Data.Errors;
            }
            return(response);
        }
Пример #22
0
        public GenericAjaxResponse <List <ExternalUserInfo> > GetAllUsers()
        {
            var request  = new RestRequest("api/Userinfo/ListUsers", Method.GET);
            var response = _restClient.Execute <GenericResponse <List <AHP.Core.DTO.ExternalUserInfo> > >(request);

            if (response.ResponseStatus == ResponseStatus.Completed)
            {
                GenericAjaxResponse <List <ExternalUserInfo> > apiResponse = new GenericAjaxResponse <List <ExternalUserInfo> >();
                apiResponse.Success = response.Data.Success;
                apiResponse.Data    = response.Data.Data;
                apiResponse.Errors  = response.Data.Errors;
                return(apiResponse);
            }
            else
            {
                return(null);
            }
        }
Пример #23
0
        public GenericAjaxResponse <List <TableauViewInfo> > GetTableauViews()
        {
            GenericAjaxResponse <List <TableauViewInfo> > apiResponse = new GenericAjaxResponse <List <TableauViewInfo> >();
            RestRequest restRequest = new RestRequest("api/Userinfo/GetAllTableauViews", Method.POST);
            IRestResponse <GenericResponse <List <TableauViewInfo> > > restResponse = _restClient.Execute <GenericResponse <List <TableauViewInfo> > >(restRequest);

            if (restResponse.StatusCode == System.Net.HttpStatusCode.OK)
            {
                apiResponse.Data    = restResponse.Data.Data;
                apiResponse.Success = restResponse.Data.Success;
                apiResponse.Errors  = restResponse.Data.Errors;
            }
            else
            {
                apiResponse.Success = false;
                apiResponse.Errors.Add("Could not get list of tableau views. Please try again.");
            }
            return(apiResponse);
        }
Пример #24
0
        public GenericAjaxResponse <ExternalUserInfo> GetUserDetails(string username)
        {
            var request = new RestRequest("api/Userinfo/UserDetails", Method.POST);

            request.AddQueryParameter("username", username);
            var response = _restClient.Execute <GenericResponse <ExternalUserInfo> >(request);

            if (response.ResponseStatus == ResponseStatus.Completed && response.Data != null)
            {
                GenericAjaxResponse <ExternalUserInfo> apiResponse = new GenericAjaxResponse <ExternalUserInfo>();
                apiResponse.Success = response.Data.Success;
                apiResponse.Data    = response.Data.Data;
                apiResponse.Errors  = response.Data.Errors;
                return(apiResponse);
            }
            else
            {
                return(null);
            }
        }
Пример #25
0
        public GenericAjaxResponse <string> GetTableauAccountname(string userName)
        {
            GenericAjaxResponse <string> apiResponse = new GenericAjaxResponse <string>();
            RestRequest restRequest = new RestRequest("api/Userinfo/GetTableauAccountname", Method.POST);

            restRequest.AddQueryParameter("username", userName);
            IRestResponse <GenericResponse <string> > restResponse = _restClient.Execute <GenericResponse <string> >(restRequest);

            if (restResponse.StatusCode == System.Net.HttpStatusCode.OK)
            {
                apiResponse.Data    = restResponse.Data.Data;
                apiResponse.Success = restResponse.Data.Success;
                apiResponse.Errors  = restResponse.Data.Errors;
            }
            else
            {
                apiResponse.Success = false;
                apiResponse.Errors.Add("Could not process your request");
            }
            return(apiResponse);
        }
Пример #26
0
        public GenericAjaxResponse <List <TableauViewUserAssociation> > ListViewAssociations(string viewId)
        {
            GenericAjaxResponse <List <TableauViewUserAssociation> > apiResponse = new GenericAjaxResponse <List <TableauViewUserAssociation> >();
            RestRequest restRequest = new RestRequest("api/Userinfo/GetAllViewAssociation", Method.POST);

            restRequest.AddQueryParameter("viewId", viewId);
            IRestResponse <GenericResponse <List <TableauViewUserAssociation> > > restResponse = _restClient.Execute <GenericResponse <List <TableauViewUserAssociation> > >(restRequest);

            if (restResponse.StatusCode == System.Net.HttpStatusCode.OK)
            {
                apiResponse.Data    = restResponse.Data.Data;
                apiResponse.Success = restResponse.Data.Success;
                apiResponse.Errors  = restResponse.Data.Errors;
            }
            else
            {
                apiResponse.Success = false;
                apiResponse.Errors.Add("Could not get list of users. Please try again.");
            }
            return(apiResponse);
        }
Пример #27
0
        public GenericAjaxResponse <bool> UpdateTableauView(TableauViewInfo tabInfo)
        {
            var request = new RestRequest("api/Userinfo/UpdateTableauInfo", Method.POST);

            request.RequestFormat = DataFormat.Json;
            request.AddJsonBody(tabInfo);
            var response = _restClient.Execute <GenericResponse <bool> >(request);

            if (response.ResponseStatus == ResponseStatus.Completed && response.Data != null)
            {
                GenericAjaxResponse <bool> apiResponse = new GenericAjaxResponse <bool>();
                apiResponse.Success = response.Data.Success;
                apiResponse.Data    = response.Data.Data;
                apiResponse.Errors  = response.Data.Errors;
                return(apiResponse);
            }
            else
            {
                return(null);
            }
        }
Пример #28
0
        public GenericAjaxResponse <bool> SetSecurityQuestionsForUser(string userName, List <UserSecurityOption> selectedQuestions)
        {
            GenericAjaxResponse <bool> response       = new GenericAjaxResponse <bool>();
            RestRequest restRequest                   = new RestRequest("api/Userinfo/UpdateSecurityQuestions", Method.POST);
            UpdateSecurityQuestionsRequest apiRequest = new UpdateSecurityQuestionsRequest()
            {
                Username          = userName,
                SecurityQuestions = selectedQuestions
            };

            restRequest.AddJsonBody(apiRequest);
            IRestResponse <GenericResponse <bool> > restResponse = _restClient.Execute <GenericResponse <bool> >(restRequest);

            if (restResponse.StatusCode == System.Net.HttpStatusCode.OK)
            {
                response.Success = restResponse.Data.Success;
                response.Data    = restResponse.Data.Data;
                response.Errors  = restResponse.Data.Errors;
            }
            return(response);
        }
Пример #29
0
        public GenericAjaxResponse <ExternalUserInfo> UpdateUser(ExternalUserInfo externalUserAccount)
        {
            var request = new RestRequest("api/Userinfo/UpdateUser", Method.POST);

            request.RequestFormat = DataFormat.Json;
            request.AddJsonBody(externalUserAccount);
            var response = _restClient.Execute <GenericResponse <ExternalUserInfo> >(request);

            if (response.ResponseStatus == ResponseStatus.Completed && response.Data != null)
            {
                GenericAjaxResponse <ExternalUserInfo> apiResponse = new GenericAjaxResponse <ExternalUserInfo>();
                apiResponse.Success = response.Data.Success;
                apiResponse.Data    = response.Data.Data;
                apiResponse.Errors  = response.Data.Errors;
                return(apiResponse);
            }
            else
            {
                return(null);
            }
        }
Пример #30
0
        public GenericAjaxResponse <bool> DeactivateUser(string username, string email)
        {
            var request = new RestRequest("api/Userinfo/DeactivateUser", Method.POST);

            request.AddQueryParameter("username", username);
            request.AddQueryParameter("email", email);
            var response = _restClient.Execute <GenericResponse <bool> >(request);

            if (response.ResponseStatus == ResponseStatus.Completed && response.Data != null)
            {
                GenericAjaxResponse <bool> apiResponse = new GenericAjaxResponse <bool>();
                apiResponse.Success = response.Data.Success;
                apiResponse.Data    = response.Data.Data;
                apiResponse.Errors  = response.Data.Errors;
                return(apiResponse);
            }
            else
            {
                return(null);
            }
        }