private void executeDeleteCommand()
 {
     foreach (var product in OfferProducts)
     {
         if (product.ProductID == SelectedElement.ProductID)
         {
             OfferProducts.Remove(product);
             break;
         }
     }
     if (_offerProducts.Count == 0)
     {
         IsEmpty = false;
     }
 }
Ejemplo n.º 2
0
        public ActionResult Edit(int id, OfferProducts cat)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:8082/SpringMVC/servlet/");
                var putTask = client.PutAsJsonAsync <OfferProducts>("UpdateOffer", cat);
                putTask.Wait();

                var ressult = putTask.Result;
                if (ressult.IsSuccessStatusCode)
                {
                    return(RedirectToAction("Index"));
                }
                return(View(cat));
            }
        }
Ejemplo n.º 3
0
        public ActionResult Create(OfferProducts Cat)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:8082/SpringMVC/servlet/");
                var postJob = client.PostAsJsonAsync <OfferProducts>("AddOffer", Cat);
                postJob.Wait();

                var postResult = postJob.Result;
                if (postResult.IsSuccessStatusCode)
                {
                    return(RedirectToAction("Index"));
                }
                ModelState.AddModelError(string.Empty, "Server error occured. Please contact admin for help!");
                //  ViewBag.CategoryList= new SelectList(categorys, "idCategory", "nameCategory");
                return(View(Cat));
            }
        }
Ejemplo n.º 4
0
        public async Task GetAllProducts()
        {
            List <string> categories = await categoryService.GetCategories();

            var products = await ProductsService.GetProductsAsync();

            Products.Clear();

            var categorizedProducts = new List <CategorizedProducts>();

            GetOfferProducts(products).ToList().ForEach(p => OfferProducts.Add(p));

            categories.ForEach(cat => categorizedProducts.Add(new CategorizedProducts(GetCategorizedProducts(cat, products), cat)));

            Products.AddRange(categorizedProducts);
            ObservableRangeCollection <Product> offerProducts = new ObservableRangeCollection <Product>(products.Where(p => p.Offer != null));

            Products.Insert(0, new CategorizedProducts(offerProducts, "Tilbud"));
        }
Ejemplo n.º 5
0
        // GET: Category/Edit/5
        public ActionResult Edit(int id)
        {
            OfferProducts cats = null;

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:8082/SpringMVC/servlet/");
                var responseTask = client.GetAsync("GetOffer/" + id.ToString());
                responseTask.Wait();

                var result = responseTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    var readTask = result.Content.ReadAsAsync <OfferProducts>();
                    readTask.Wait();

                    cats = readTask.Result;
                }
            }
            return(View(cats));
        }
Ejemplo n.º 6
0
        public ActionResult AddOffer(int id)
        {
            Products prod = null;

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:8082/SpringMVC/servlet/");
                var responseTask = client.GetAsync("GetProduct/" + id.ToString());
                responseTask.Wait();

                var result = responseTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    var readTask = result.Content.ReadAsAsync <Products>();
                    readTask.Wait();

                    prod = readTask.Result;
                }
            }


            string idOffer = Request.Form["OfferList"].ToString();

            Console.WriteLine(idOffer);
            OfferProducts offer = null;

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:8082/SpringMVC/servlet/");
                var responseTask = client.GetAsync("GetOffer/" + idOffer);
                responseTask.Wait();

                var result = responseTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    var readTask = result.Content.ReadAsAsync <OfferProducts>();
                    readTask.Wait();

                    offer = readTask.Result;
                    Console.WriteLine(offer);
                }
            }

            Console.WriteLine(prod);
            //  prod.offerProducts = offer;

            Console.WriteLine(prod.offerProducts);

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("http://localhost:8082/SpringMVC/servlet/");
                var putTask = client.PutAsJsonAsync <Products>("affecterProduitAsOfferValue/" + id.ToString() + "/" + idOffer, prod);
                putTask.Wait();

                var ressult = putTask.Result;
                if (ressult.IsSuccessStatusCode)
                {
                    return(RedirectToAction("ListProducts"));
                }


                return(View(prod));
            }
        }