Exemplo n.º 1
0
        // GET: Cabinet/menu/List
        public ActionResult Detail(int id)
        {
            if (!SessionHelpers.IsAuthentificated())
            {
                return(RedirectToAction("Login", "Authorize"));
            }

            if (id < 1)
            {
                return(HttpNotFound());
            }
            var operation = new LoadCategoriesOperation();

            operation.ExcecuteTransaction();

            var operation2 = new LoadProductOperation(id);

            operation2.ExcecuteTransaction();
            if (operation2._product == null)
            {
                return(HttpNotFound());
            }

            ViewBag.IsSave = false;
            return(View(new ProductModel {
                Categories = operation._categories, Product = operation2._product
            }));
        }
Exemplo n.º 2
0
        public ActionResult Products(int id)
        {
            if (id < 1)
            {
                return(HttpNotFound());
            }
            var op = new LoadProductsOperation(1, ConstV.ItemsPerPage, id);

            op.ExcecuteTransaction();
            if (!op.Success)
            {
                return(HttpNotFound());
            }

            var op2 = new LoadPagesDescOperation("menu", "index");

            op2.ExcecuteTransaction();
            var op3 = new LoadCategoriesOperation();

            op3.ExcecuteTransaction();
            var model = new MenuModel
            {
                PageDescription = op2._pageDescription,
                Categories      = op3._categories,
                Products        = op._products,
            };

            ViewBag.Main = false;
            return(View("Index", model));
        }
Exemplo n.º 3
0
        public ActionResult Add()
        {
            if (!SessionHelpers.IsAuthentificated())
            {
                return(RedirectToAction("Login", "Authorize"));
            }

            ViewBag.IsSave = false;
            var operation = new LoadCategoriesOperation();

            operation.ExcecuteTransaction();
            return(View(operation._categories));
        }
Exemplo n.º 4
0
        // GET: Cabinet/Menu/List
        public ActionResult List()
        {
            if (!SessionHelpers.IsAuthentificated())
            {
                return(RedirectToAction("Login", "Authorize"));
            }

            var operation = new LoadCategoriesOperation();

            operation.ExcecuteTransaction();
            var operation2 = new LoadAllProductsOperation(0);

            operation2.ExcecuteTransaction();
            return(View(new MenuListModel {
                Categories = operation._categories, Products = operation2._products
            }));
        }
Exemplo n.º 5
0
        public ActionResult Add(Product model, HttpPostedFileBase image)
        {
            if (!SessionHelpers.IsAuthentificated())
            {
                return(RedirectToAction("Login", "Authorize"));
            }

            AddProductOperation op = new AddProductOperation(model.CategoryId, model.Description, model.Title, model.Price, model.IsHot, image);

            op.ExcecuteTransaction();

            var operation = new LoadCategoriesOperation();

            operation.ExcecuteTransaction();

            ViewBag.IsSave = true;
            return(View(operation._categories));
        }
Exemplo n.º 6
0
        // GET: Menu
        public ActionResult Index()
        {
            var op = new LoadPagesDescOperation("menu", "index");

            op.ExcecuteTransaction();
            var op2 = new LoadCategoriesOperation();

            op2.ExcecuteTransaction();
            var op3 = new LoadHotProductsOperation(1, ConstV.ItemsPerPage);

            op3.ExcecuteTransaction();
            var model = new MenuModel
            {
                PageDescription = op._pageDescription,
                Categories      = op2._categories,
                Products        = op3._products,
            };

            ViewBag.Main = true;
            return(View(model));
        }
Exemplo n.º 7
0
        public ActionResult Detail(Product model, HttpPostedFileBase image)
        {
            if (!SessionHelpers.IsAuthentificated())
            {
                return(RedirectToAction("Login", "Authorize"));
            }
            UpdateProductOperation op = new UpdateProductOperation(model.Id, model.CategoryId, model.Description, model.Title, model.Price, model.IsHot, image);

            op.ExcecuteTransaction();
            if (op._product == null)
            {
                return(HttpNotFound());
            }
            var operation = new LoadCategoriesOperation();

            operation.ExcecuteTransaction();
            ViewBag.IsSave = true;

            return(View(new ProductModel {
                Categories = operation._categories, Product = op._product
            }));
        }