예제 #1
0
        // api/saft/ProductCustomers?vid=C0001
        // api/saft/CustomersBoughtProducts?vid=PT505678900_C
        // api/saft/Accounts/?vid=11
        // api/saft/Customers/?vid=ES989922456_C
        // api/saft/Products/?vid=A0001
        public HttpResponseMessage Get(string id, string vid)
        {
            HttpResponseMessage response = null;
            string body = "";


            switch (id)
            {
            case "ProductCustomers":
                body = MongoConnection.GetProductCustomers(vid);
                break;

            case "CustomersBoughtProducts":
                body = MongoConnection.GetCustomerBoughtProducts(vid);
                break;

            case "Accounts":
                body = MongoConnection.GetCollectionById(id, "AccountID", vid);
                break;

            case "Customers":
                body = MongoConnection.GetCollectionById(id, "CustomerID", vid);
                break;

            case "Products":
                body = MongoConnection.GetCollectionById(id, "ProductCode", vid);
                break;
            }

            response         = this.Request.CreateResponse(HttpStatusCode.OK);
            response.Content = new StringContent(body, Encoding.UTF8, "application/json");

            return(response);
        }