Ejemplo n.º 1
0
        public dynamic SearchSubscriptionTypes(SubscriptionTypeSearchRequest request)
        {
            SearchByID searchByID = new SearchByID();

            SearchByName searchByName = new SearchByName();

            SearchByPriceRange searchByPriceRange = new SearchByPriceRange();

            List <string> errors = new List <string>();

            DBC dbc = DBC.DatabaseConnection();

            if (!string.IsNullOrWhiteSpace(request.SubscriptionID))
            {
                return(searchByID
                       .SearchEntitiesByID(dbc, "SubscriptionTypes", request.SubscriptionID, errors));
            }

            if (!string.IsNullOrWhiteSpace(request.SubscriptionName))
            {
                return(searchByName
                       .SearchSubscriptionTypesByName(dbc, request.SubscriptionName, errors));
            }

            if (!string.IsNullOrWhiteSpace(request.SubscriptionMonthlyFeeMin) &&
                !string.IsNullOrWhiteSpace(request.SubscriptionMonthlyFeeMax))
            {
                return(searchByPriceRange
                       .SearchSubscriptionTypesByPriceRange(dbc,
                                                            request.SubscriptionMonthlyFeeMin,
                                                            request.SubscriptionMonthlyFeeMax,
                                                            errors));
            }
            else if (string.IsNullOrWhiteSpace(request.SubscriptionMonthlyFeeMin) &&
                     !string.IsNullOrWhiteSpace(request.SubscriptionMonthlyFeeMax))
            {
                return(searchByPriceRange
                       .SearchSubscriptionTypesByPriceRange(dbc,
                                                            "0",
                                                            request.SubscriptionMonthlyFeeMax,
                                                            errors));
            }
            else if (!string.IsNullOrWhiteSpace(request.SubscriptionMonthlyFeeMin) &&
                     string.IsNullOrWhiteSpace(request.SubscriptionMonthlyFeeMax))
            {
                return(searchByPriceRange
                       .SearchSubscriptionTypesByPriceRange(dbc,
                                                            request.SubscriptionMonthlyFeeMin,
                                                            "0",
                                                            errors));
            }
            else
            {
                return(new NoParameterSubscriptionTypeResponse("No subscription types found. Please check your request for validity against the fields below."));
            }
        }
Ejemplo n.º 2
0
        public dynamic GetSubscriptionType(SubscriptionTypeSearchRequest request)
        {
            SubscriptionTypeSearchSummary subscriptionTypeSearchSummary = new SubscriptionTypeSearchSummary();

            if (CheckClientSecret())
            {
                return(subscriptionTypeSearchSummary.SearchSubscriptionTypes(request));
            }
            else
            {
                return(new HttpResponseMessage(System.Net.HttpStatusCode.BadRequest));
            }
        }