Esempio n. 1
0
 public IHttpResponse Register(IHttpSession session)
 {
     if (session.IsAuthenticated())
     {
         return(new RedirectResponse("/"));
     }
     return(this.FileViewResponse("Account/register"));
 }
Esempio n. 2
0
        public IHttpResponse Login(IHttpSession session)
        {
            if (session.IsAuthenticated())
            {
                return(new RedirectResponse("/"));
            }

            return(this.FileViewResponse("Account/login"));
        }
        public IHttpResponse AddGame(IHttpSession session)
        {
            if (!session.IsAuthenticated())
            {
                return(new RedirectResponse("/login"));
            }

            LoginViewModel user = session.Get <LoginViewModel>(SessionStore.CurrentUserKey);

            if (!user.IsAdmin)
            {
                return(new RedirectResponse("/"));
            }

            return(this.FileViewResponse("Game/add-game"));
        }
        public IHttpResponse AdminGames(IHttpSession session)
        {
            if (!session.IsAuthenticated())
            {
                return(new RedirectResponse("/login"));
            }

            LoginViewModel user = session.Get <LoginViewModel>(SessionStore.CurrentUserKey);

            if (!user.IsAdmin)
            {
                return(new RedirectResponse("/"));
            }

            List <GameViewModel> games = this.gameService.GetAdminGames();

            StringBuilder sb = new StringBuilder();

            foreach (GameViewModel game in games)
            {
                sb.Append(@"<tr class=""table-warning"">" +
                          $@"<th scope=""row"">{game.SequelNumber}</th>" +
                          $"<td>{game.Title}</td>" +
                          $" <td>{game.Size:f1} GB</td>" +
                          $"<td>{game.Price:f1} &euro;</td>" +
                          " <td>" +
                          $@"<a href=""/edit-game/{game.Id}"" class=""btn btn-warning btn-sm"">Edit</a>" +
                          $@"<a href=""/delete-game/{game.Id}"" class=""btn btn-danger btn-sm"">Delete</a>" +
                          "</td>" +
                          "</tr>");
            }

            string result = sb.ToString();

            this.ViewData["show-games"] = "block";
            this.ViewData["games"]      = result;

            return(this.FileViewResponse("Game/admin-games"));
        }
        public IHttpResponse DeleteGame(IHttpSession session, string urlParameter)
        {
            if (!session.IsAuthenticated() || !session.Get <LoginViewModel>(SessionStore.CurrentUserKey).IsAdmin)
            {
                return(new RedirectResponse("/"));
            }

            int id = int.Parse(urlParameter);

            GameToAddOrEditViewModel game = this.gameService.GetById(id);

            this.ViewData["id"]          = game.Id.ToString();
            this.ViewData["title"]       = game.Title;
            this.ViewData["description"] = game.Description;
            this.ViewData["thumbnail"]   = game.ThumbnailUrl != null ? game.ThumbnailUrl : string.Empty;
            this.ViewData["trailer"]     = game.Trailer;
            this.ViewData["price"]       = game.Price.ToString("f2");
            this.ViewData["size"]        = game.Size.ToString("f1");
            this.ViewData["date"]        = game.ReleaseDate.ToString("yyyy-MM-dd");

            return(this.FileViewResponse("Game/delete-game"));
        }