Example #1
0
        public ActionResult Edit(Invoice invoice)
        {
            try
            {
                // TODO: Add update logic here
                invoice = APIConsumer <Invoice> .GetObject(PATH, invoice.Id.ToString());

                if (invoice.IsPaid == false)
                {
                    invoice.IsPaid = true;
                }
                else
                {
                    invoice.IsPaid = false;
                }

                APIConsumer <Models.Webshop.Invoice> .EditObject(PATH, invoice.Id.ToString(), invoice);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Example #2
0
        // GET: Product/Details/5

        public ActionResult Details(int id)
        {
            Product product = APIConsumer <Product> .GetObject("product", id.ToString());

            IEnumerable <Course> courses = this.courses.Where(i => i.ProductId == product.Id);

            product.Courses = courses.ToList();
            return(View(product));
        }
Example #3
0
        // GET: Invoice/Delete/5
        public ActionResult Delete(int id)
        {
            Invoice invoice = APIConsumer <Invoice> .GetObject(PATH, id.ToString());

            if (invoice.Deleted == false)
            {
                return(View(invoice));
            }

            else
            {
                return(RedirectToAction("DeletedIndex"));
            }
        }
Example #4
0
        public ActionResult Delete(Invoice invoice)
        {
            try
            {
                // TODO: Add delete logic here
                invoice = APIConsumer <Invoice> .GetObject(PATH, (invoice.Id).ToString());

                invoice.Deleted = true;
                APIConsumer <Models.Webshop.Invoice> .EditObject(PATH, invoice.Id.ToString(), invoice);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Example #5
0
        // GET: MyOrder
        public ActionResult Details(int id)
        {
            orderDetails = new List <ShoppingCart>();
            decimal total = 0;

            foreach (Invoice item in invoices)
            {
                if (item.Email == user.Email)
                {
                    foreach (InvoiceDetail detail in details)
                    {
                        if (detail.InvoiceId == id)
                        {
                            if (detail.ProductId != 0)
                            {
                                Product products =
                                    APIConsumer <Product> .GetObject("product", detail.ProductId.ToString());

                                total += (products.Price * detail.Pieces);
                                orderDetails.Add(new ShoppingCart()
                                {
                                    Product = products, Quantity = detail.Pieces
                                });
                            }

                            if (detail.CourseId != 0)
                            {
                                Course courses = APIConsumer <Course> .GetObject("course", detail.CourseId.ToString());

                                total += (courses.Price * detail.Pieces);
                                orderDetails.Add(new ShoppingCart()
                                {
                                    Course = courses, Quantity = detail.Pieces
                                });
                            }
                        }
                    }

                    ViewBag.total = total;
                    break;
                }
            }

            return(View(orderDetails));
        }
Example #6
0
        // GET: Invoice/Edit/5
        public ActionResult Edit(int id)
        {
            Invoice invoice = APIConsumer <Invoice> .GetObject(PATH, id.ToString());

            string email   = invoice.Email;
            string surname = invoice.Surname;

            string firstname = invoice.Firstname;

            if (invoice.Deleted == false)
            {
                invoice.Email     = email;
                invoice.Surname   = surname;
                invoice.Firstname = firstname;
                return(View(invoice));
            }

            else
            {
                return(RedirectToAction("DeletedIndex"));
            }
        }
Example #7
0
 public ActionResult Edit(int id)
 {
     ViewBag.products = products;
     return(View(APIConsumer <Course> .GetObject("course", id.ToString())));
 }
Example #8
0
 public ActionResult Details(int id)
 {
     return(View(APIConsumer <Course> .GetObject("course", id.ToString())));
 }
        public ActionResult Buy(int id, bool?getBool)
        {
            if (getBool == false)
            {
                Course courses = APIConsumer <Course> .GetObject("course", id.ToString());

                if (Session["cart"] == null)
                {
                    List <ShoppingCart> cart = new List <ShoppingCart>();
                    cart.Add(new ShoppingCart()
                    {
                        Course = courses, Quantity = 1
                    });
                    Session["cart"]  = cart;
                    Session["count"] = 1;
                }
                else
                {
                    List <ShoppingCart> cart = (List <ShoppingCart>)Session["cart"];

                    int index = ItemExists(id, false);
                    if (index != -1)
                    {
                        cart[index].Quantity++;
                        Session["count"] = Convert.ToInt32(Session["count"]) + 1;
                    }
                    else
                    {
                        cart.Add(new ShoppingCart()
                        {
                            Course = courses, Quantity = 1
                        });
                        Session["count"] = Convert.ToInt32(Session["count"]) + 1;
                    }

                    Session["card"] = cart;
                }
                return(RedirectToAction("Index", "Course"));
            }
            if (getBool == true)
            {
                Product products = APIConsumer <Product> .GetObject("product", id.ToString());

                if (Session["cart"] == null)
                {
                    List <ShoppingCart> cart = new List <ShoppingCart>();
                    cart.Add(new ShoppingCart()
                    {
                        Product = products, Quantity = 1
                    });
                    Session["cart"]  = cart;
                    Session["count"] = 1;
                }
                else
                {
                    List <ShoppingCart> cart = (List <ShoppingCart>)Session["cart"];

                    int index = ItemExists(id, true);
                    if (index != -1)
                    {
                        cart[index].Quantity++;
                        Session["count"] = Convert.ToInt32(Session["count"]) + 1;
                    }
                    else
                    {
                        cart.Add(new ShoppingCart()
                        {
                            Product = products, Quantity = 1
                        });
                        Session["count"] = Convert.ToInt32(Session["count"]) + 1;
                    }

                    Session["card"] = cart;
                }

                return(RedirectToAction("Index", "Product"));
            }

            return(null);
        }
Example #10
0
 public ActionResult Delete(int id)
 {
     return(View(APIConsumer <Product> .GetObject(PATH, id.ToString())));
 }
Example #11
0
 // GET: ProductPrice/Edit/5
 public ActionResult Edit(int id)
 {
     return(View(APIConsumer <ProductPrice> .GetObject(PATH, id.ToString())));
 }
Example #12
0
 // GET: Invoice/Details/5
 public ActionResult Details(int id)
 {
     return(View(APIConsumer <Invoice> .GetObject(PATH, id.ToString())));
 }