示例#1
0
        public HttpResponseMessage add(ProductAccessory post)
        {
            // Check for errors
            if (post == null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The post is null"));
            }
            else if (Product.MasterPostExists(post.product_id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The product does not exist"));
            }
            else if (Product.MasterPostExists(post.accessory_id) == false)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The accessory does not exist"));
            }
            else if (ProductAccessory.GetOneById(post.product_id, post.accessory_id) != null)
            {
                return(Request.CreateResponse <string>(HttpStatusCode.BadRequest, "The product accessory already exists"));
            }

            // Add the post
            ProductAccessory.Add(post);

            // Return the success response
            return(Request.CreateResponse <string>(HttpStatusCode.OK, "The post has been added"));
        } // End of the add method
示例#2
0
        public ProductAccessory get_by_id(Int32 id = 0, Int32 accessoryId = 0)
        {
            // Create the post to return
            ProductAccessory post = ProductAccessory.GetOneById(id, accessoryId);

            // Return the post
            return(post);
        } // End of the get_by_id method