Ejemplo n.º 1
0
        private void GetServices(HttpContext context)
        {
            short serviceId  = 0;
            bool  onlyActive = true;
            bool  includeServiceProperties = true;
            byte  productId = 0;

            if (context.Request["ProductId"] == null || !byte.TryParse(context.Request["ProductId"].ToString(), out productId))
            {
                GenerateErrorResponse(400, string.Format("ProductId is mandatory", context.Request["ProductId"].ToString()));
            }
            if (context.Request["ServiceId"] != null && !short.TryParse(context.Request["ServiceId"].ToString(), out serviceId))
            {
                GenerateErrorResponse(400, string.Format("ServiceId value ({0}) is not a valid number", context.Request["ServiceId"].ToString()));
            }
            if (context.Request["OnlyActive"] != null && !bool.TryParse(context.Request["OnlyActive"].ToString(), out onlyActive))
            {
                GenerateErrorResponse(400, string.Format("OnlyActive value ({0}) is not a valid boolean value", context.Request["OnlyActive"].ToString()));
            }
            if (context.Request["IncludeServiceProperties"] != null && !bool.TryParse(context.Request["IncludeServiceProperties"].ToString(), out includeServiceProperties))
            {
                GenerateErrorResponse(400, string.Format("IncludeServiceProperties value ({0}) is not a valid boolean value", context.Request["IncludeServiceProperties"].ToString()));
            }

            TablePreferences servicesTablePreferences = new TablePreferences("", "", true, false);
            Dictionary <string, TablePreferences> servicesDictionary = new Dictionary <string, TablePreferences>();

            servicesDictionary.Add("Services", servicesTablePreferences);
            OrdersManagement.Core.Client client = new OrdersManagement.Core.Client(responseFormat: OrdersManagement.ResponseFormat.JSON);
            context.Response.Write(client.GetServices(productId: productId, serviceId: serviceId, includeServiceProperties: includeServiceProperties, onlyActive: onlyActive, tablePreferences: servicesDictionary));
        }