Exemple #1
0
        public void Configure(IAppRoutingConfig appRouteConfig)
        {
            appRouteConfig.AnonymousPaths.Add("/login");
            appRouteConfig.AnonymousPaths.Add("/register");

            appRouteConfig.Get("/", request => new HomeController().Index());
            appRouteConfig.Get("/about", request => new HomeController().About());
            appRouteConfig.Get("/add", request => new ProductsController().Add());
            appRouteConfig.Post("/add", request => new ProductsController().Add(new AddProductViewModel
            {
                Name     = request.FormData["name"],
                Price    = decimal.Parse(request.FormData["price"]),
                ImageUrl = request.FormData["imageUrl"]
            }));
            appRouteConfig.Get("/search", request => new ProductsController().Search(request));
            appRouteConfig.Get("/register", request => new AccountController().Register());
            appRouteConfig.Post("/register", request => new AccountController().Register(request, new RegisterUserViewModel
            {
                Username        = request.FormData["username"],
                Password        = request.FormData["password"],
                ConfirmPassword = request.FormData["confirm-password"]
            }));
            appRouteConfig.Get("/login", request => new AccountController().Login());
            appRouteConfig.Post("/login", request => new AccountController().Login(request, new LoginUserViewModel
            {
                Username = request.FormData["username"],
                Password = request.FormData["password"]
            }));
            appRouteConfig.Get("/shopping/add/{(?<id>[0-9]+)}", request => new ShoppingController().AddToCart(request));
            appRouteConfig.Get("/cart", request => new ShoppingController().ShowCart(request));
            appRouteConfig.Post("/shopping/finish-order", request => new ShoppingController().FinishOrder(request));
            appRouteConfig.Post("/logout", request => new AccountController().Logout(request));
            appRouteConfig.Get("/profile", request => new AccountController().Profile(request));
            appRouteConfig.Get("/cakes/{(?<id>[0-9]+)}", request => new ProductsController().Details(int.Parse(request.UrlParameters["id"])));
            appRouteConfig.Get("/orders", request => new ShoppingController().ShowOrders(request));
            appRouteConfig.Get("/orderDetails/{(?<id>[0-9]+)}", request => new ShoppingController().OrderDetails(int.Parse(request.UrlParameters["id"])));
        }
Exemple #2
0
        public void Configure(IAppRoutingConfig appRouteConfig)
        {
            appRouteConfig.AnonymousPaths.Add("/account/login");
            appRouteConfig.AnonymousPaths.Add("/account/register");

            appRouteConfig.Get("/", request => new HomeController(request).Home());
            appRouteConfig.Get("/home/games/info/{(?<id>[0-9]+)}", request => new HomeController(request).Info());
            appRouteConfig.Get("/account/login", request => new AccountController(request).Login());
            appRouteConfig.Post("/account/login", request => new AccountController(request).Login(new LoginUserViewModel
            {
                Email    = request.FormData["email"],
                Password = request.FormData["password"]
            }));
            appRouteConfig.Get("/account/register", request => new AccountController(request).Register());
            appRouteConfig.Post("/account/register", request => new AccountController(request).Register(new RegisterUserViewModel
            {
                Email           = request.FormData["email"],
                Name            = request.FormData["fullName"],
                Password        = request.FormData["password"],
                ConfirmPassword = request.FormData["confirm-password"]
            }));
            appRouteConfig.Get("/account/logout", request => new AccountController(request).Logout());

            appRouteConfig.Get("/admin/games/add", request => new AdminController(request).AddGame());
            appRouteConfig.Post("/admin/games/add", request => new AdminController(request).AddGame(new AddGameViewModel
            {
                Title       = request.FormData["title"],
                Description = request.FormData["description"],
                Image       = request.FormData["image"],
                TrailerId   = request.FormData["trailerId"],
                Price       = decimal.Parse(request.FormData["price"]),
                Size        = double.Parse(request.FormData["size"]),
                ReleaseDate = DateTime.ParseExact(request.FormData["releaseDate"], "yyyy-MM-dd", CultureInfo.InvariantCulture)
            }));

            appRouteConfig.Get("/admin/games/list", request => new AdminController(request).ListAllGames());
            appRouteConfig.Get("/admin/games/edit/{(?<id>[0-9]+)}", request => new AdminController(request).EditGame());
            appRouteConfig.Post("/admin/games/edit/{(?<id>[0-9]+)}", request => new AdminController(request).EditGame(new AddGameViewModel
            {
                Title       = request.FormData["title"],
                Description = request.FormData["description"],
                Image       = request.FormData["image"],
                TrailerId   = request.FormData["trailerId"],
                Price       = decimal.Parse(request.FormData["price"]),
                Size        = double.Parse(request.FormData["size"]),
                ReleaseDate = DateTime.ParseExact(request.FormData["releaseDate"], "yyyy-MM-dd", CultureInfo.InvariantCulture)
            }));

            appRouteConfig.Get("/admin/games/delete/{(?<id>[0-9]+)}", request => new AdminController(request).DeleteGameDetails());
            appRouteConfig.Post("/admin/games/delete/{(?<id>[0-9]+)}", request => new AdminController(request).Delete());

            appRouteConfig.Get("/shopping/buy/{(?<id>[0-9]+)}", request => new ShoppingController(request).AddToCart());
            appRouteConfig.Get("/shopping/cart", request => new ShoppingController(request).ShowCart());
            appRouteConfig.Get("/shopping/cart/remove/{(?<id>[0-9]+)}", request => new ShoppingController(request).RemoveFromCart());
            appRouteConfig.Post("/shopping/cart", request => new ShoppingController(request).Order());
        }