Esempio n. 1
0
        internal override string Execute(NameValueCollection commandParameters)
        {
            int    categoryID;
            int    startPageNo;
            int    endPageNo;
            string sortBy;
            string sortByEnumString;
            int    userID;

            if (!Helper.TryGetUserID(_session, out userID))
            {
                userID = -1;
            }

            string error = ValidateIntParameter(commandParameters, "categoryId", out categoryID);

            if (error != String.Empty)
            {
                return(error);
            }

            error = ValidateIntParameter(commandParameters, "startPageNo", out startPageNo);

            if (error != String.Empty)
            {
                return(error);
            }

            error = ValidateIntParameter(commandParameters, "endPageNo", out endPageNo);

            if (error != String.Empty)
            {
                return(error);
            }

            error = ValidateStringParameter(commandParameters, "sortBy", out sortBy);

            if (error != String.Empty)
            {
                return(error);
            }

            error = GetSortChannelsByFromConfig(sortBy, out sortByEnumString);

            if (error != String.Empty)
            {
                return(error);
            }

            // validate Sort By enum
            SortChannelsBy sortChannelsBy;

            error = TryParseSortChannelsBy(typeof(SortChannelsBy), sortByEnumString, out sortChannelsBy);

            if (error != String.Empty)
            {
                return(error);
            }

            PageChannelData pageChannelData;

            BLClient client = null;

            // call WCF BLL Method
            try
            {
                client = new BLClient();

                pageChannelData = client.GetChannelListByCategoryID(userID, categoryID, startPageNo, endPageNo, sortChannelsBy);
            }
            catch (Exception exception)
            {
                return(ErrorWrapper.SendError(exception.Message));
            }
            finally
            {
                if (client != null)
                {
                    client.Dispose();
                }
            }

            return(Flatten(pageChannelData));
        }