public async Task PostsToTheCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new ProductsClient(connection);

                var newProduct   = new NewProduct("name");
                var customFields = new Dictionary <string, ICustomField>()
                {
                    { "5913c8efdcf5c641a516d1fbd498235544b1b195", new IntCustomField(123) }
                };

                newProduct.CustomFields = customFields;
                await client.Create(newProduct);

                Received.InOrder(async() =>
                {
                    await connection.Post <Product>(Arg.Is <Uri>(u => u.ToString() == "products"),
                                                    Arg.Is <NewProduct>(d => d.Name == "name" && d.CustomFields == customFields));
                });
            }
        public ActionResult Create(ProductViewModel cvm, HttpPostedFileBase file)
        {
            //HttpPostedFileBase file = Request.Files[0];
            if (ModelState.IsValid)
            {
                if (file != null)
                {
                    string ImageName    = Path.GetFileName(file.FileName);
                    string physicalPath = Server.MapPath("~/Product_Images/" + ImageName);

                    // save image in folder
                    file.SaveAs(physicalPath);
                    cvm.product.Pictures = ImageName;
                }
                ProductsClient CC      = new ProductsClient();
                int            Storeid = CC.Storeid(Convert.ToInt32(Session["userID"]));
                cvm.product.Store_ID = Storeid;
                CC.Create(cvm.product);
            }

            return(RedirectToAction("Index"));
        }
            public async Task EnsuresNonNullArguments()
            {
                var client = new ProductsClient(Substitute.For <IApiConnection>());

                await Assert.ThrowsAsync <ArgumentNullException>(() => client.Create(null));
            }