Esempio n. 1
0
        public ActionResult Create(Product product, List<string> imageURL, int categoryID)
        {
            product.Images = new List<Image>();

            if (imageURL.All(x => string.IsNullOrWhiteSpace(x)))
            {
                Image image = new Image() { URL = "http://i.imgur.com/qfkGmIV.png" };
                product.Images.Add(image);
            }
            else
            {
                for (int i = 0; i < imageURL.Count; i++)
                {
                    if(!string.IsNullOrWhiteSpace(imageURL[i]))
                    {
                        Image image = new Image() { URL = imageURL[i] };
                        product.Images.Add(image);
                    }
                }

            }

            product.ChildCategory = facade.GetCategoryGateway().ReadChildCategory(categoryID);
            product.CreationDate = DateTime.Now;

            facade.GetProductGateway().Create(product);
            return Redirect("Index");
        }
Esempio n. 2
0
 public Product Update(Product t)
 {
     using (var client = new HttpClient())
     {
         HttpResponseMessage response =
             client.PutAsJsonAsync("http://localhost:54980/api/products/" + t.ID, t).Result;
         return response.Content.ReadAsAsync<Product>().Result;
     }
 }
Esempio n. 3
0
 public ActionResult Update(Product product, List<String> imageURL, int categoryID)
 {
     product.Images = new List<Image>();
     for (int i = 0; i < imageURL.Count; i++)
     {
         Image image = new Image() { URL = imageURL[i] };
         product.Images.Add(image);
     }
     product.ChildCategory = facade.GetCategoryGateway().ReadChildCategory(categoryID);
     facade.GetProductGateway().Update(product);
     return Redirect("Index");
 }