Exemple #1
0
        public HttpResponseMessage GetPageUrls(int portalId, int tabId)
        {
            try
            {
                if (SecurityService.IsPagesAdminUser() == false)
                {
                    return(this.GetForbiddenResponse());
                }
                PagesControllerImpl pageController = new PagesControllerImpl();

                var pageUrls = pageController.GetPageUrls(portalId, tabId);

                var result = pageUrls.Select(m => new
                {
                    Url         = m.Path,
                    UrlType     = m.StatusCode.Value,
                    GeneratedBy = m.IsSystem ? Constants.AUTOMATIC : m.UserName
                });

                return(Request.CreateResponse <dynamic>(HttpStatusCode.OK, result));;
            }
            catch (Exception ex)
            {
                LogError(ex);
                Exceptions.LogException(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, new HttpError(ex.Message)
                {
                    { Constants.RESPONSE_SUCCESS, false }
                }));
            }
        }
Exemple #2
0
        public HttpResponseMessage GetPagesList(int portalId, string searchKey = "", int pageIndex = -1, int pageSize = 10, string sortBy = "", string sortType = "", bool?deleted = false)
        {
            int total = 0;

            try
            {
                if (SecurityService.IsPagesAdminUser() == false)
                {
                    return(this.GetForbiddenResponse());
                }

                PagesControllerImpl pageController = new PagesControllerImpl();

                var pages = pageController.GetPagesList(portalId: portalId,
                                                        total: out total,
                                                        searchKey: searchKey,
                                                        pageIndex: pageIndex,
                                                        pageSize: pageSize,
                                                        sortBy: sortBy,
                                                        sortType: sortType,
                                                        deleted: deleted
                                                        );

                var result = pages.Select(p => new
                {
                    Id               = p.TabID,
                    Name             = p.LocalizedTabName,
                    Title            = p.Title,
                    Description      = p.Description,
                    Keywords         = p.KeyWords,
                    Priority         = p.SiteMapPriority,
                    PrimaryUrl       = pageController.GetPageUrls(p.PortalID, p.TabID).FirstOrDefault().Path,
                    LastUpdated      = string.Format(Constants.FORMAT_LASTUPDATED, (p.LastModifiedByUserID == Null.NullInteger ? Constants.SYSTEM : p.LastModifiedByUser(portalId).FirstName), (p.LastModifiedByUserID == Null.NullInteger ? Constants.ACCOUNT : p.LastModifiedByUser(portalId).LastName), p.LastModifiedOnDate.ToString(Constants.FORMAT_DATE)),
                    IsVisible        = p.IsVisible,
                    IsAllowedSearch  = p.AllowIndex,
                    IsDisabled       = p.DisableLink,
                    IsIndexed        = p.Indexed,
                    HasBeenPublished = p.HasBeenPublished
                });

                //string sortOn = sortBy.ToLowerInvariant();
                //string sortOrder = sortType.ToLowerInvariant();

                //if (String.IsNullOrEmpty(sortBy) == false)
                //{
                //    switch (sortBy.ToLowerInvariant())
                //    {
                //        case Constants.NAME:
                //            result = sortOrder == Constants.ASC ? result.OrderBy(x => x.Name) : result.OrderByDescending(x => x.Name);
                //            break;
                //        case Constants.TITLE:
                //            result = sortOrder == Constants.ASC ? result.OrderBy(x => x.Title) : result.OrderByDescending(x => x.Title);
                //            break;
                //        default:
                //            break;
                //    }
                //}

                return(Request.CreateResponse <dynamic>(HttpStatusCode.OK, new { Total = total.ToString(), result }));
            }
            catch (Exception ex)
            {
                LogError(ex);
                Exceptions.LogException(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, new HttpError(ex.Message)
                {
                    { Constants.RESPONSE_SUCCESS, false }
                }));
            }
        }