コード例 #1
0
        private void GetResponseHtml(IEnumerable <ListGamesViewModel> games, StringBuilder gamesAsString)
        {
            string adminDisplay = this.Authentication.IsAdmin == true ? @"inline-block" : "none";

            int count = 1;

            foreach (ListGamesViewModel game in games)
            {
                if (count % 3 == 1)
                {
                    gamesAsString.AppendLine(@"<div class=""card-group"">");
                }

                gamesAsString.AppendLine(
                    $@"<div class=""card col-4 thumbnail"">
                            <img style=""width: 400px; height: 400px;"" class=""card-image-top img-fluid img-thumbnail"" onerror=""this.src='https://i.ytimg.com/vi/{game.VideoId}/maxresdefault.jpg';"" src=""{game.ImageUrl}"">
                            <div class=""card-body"">
                                <h4 class=""card-title"">{game.Title}</h4>
                                <p class=""card-text""><strong>Price</strong> - {game.Price:F2}&euro;</p>
                                <p class=""card-text""><strong>Size</strong> - {game.Size:F2} GB</p>
                                <p class=""card-text"">{(CutText.Cut(game.Description))}</p>
                            </div>
                            <div class=""card-footer"">
                                <span style=""display: {adminDisplay}"">
                                    <a class=""card-button btn btn-warning"" href=""/admin/games/edit/{game.Id}"">Edit</a>
                                    <a class=""card-button btn btn-danger"" href=""/admin/games/delete/{game.Id}"">Delete</a>
                                </span>
                                <a class=""card-button btn btn-outline-primary"" href=""/games/details/{game.Id}"">Info</a>
                                <a class=""card-button btn btn-primary"" href=""/shopping/cart/add/{game.Id}"">Buy</a>
                            </div>
                       </div>
                    ");

                if (count % 3 == 0)
                {
                    gamesAsString.AppendLine("</div>");
                }

                count++;
            }
        }
コード例 #2
0
 private void GetResponseHtml(IEnumerable <CartGameDetailsViewModel> gamesInCart, StringBuilder gamesAsString)
 {
     foreach (CartGameDetailsViewModel game in gamesInCart)
     {
         gamesAsString.AppendLine(
             $@"<div class=""list-group"">
                 <div class=""list-group-item"">
                     <div class=""media"">
                         <a class=""btn btn-outline-danger btn-lg align-self-center mr-3"" href=""/shopping/cart/remove/{game.Id}"">X</a>
                           <img style=""width: 200px; height: 200px;"" class=""card-image-top img-fluid img-thumbnail"" onerror=""this.src='https://i.ytimg.com/vi/{game.VideoId}/maxresdefault.jpg';"" src=""{game.ImageUrl}"">
                             <div class=""media-body align-self-center"">
                                 <a href=""/games/details/{game.Id}""><h4 style=""margin-left: 20px"" class=""mb-1 list-group-item-heading"">{game.Title}</h4></a>
                                 <p style=""margin-left: 20px"">{CutText.Cut(game.Description)}</p>
                             </div>
                         <div class=""col-md-2 text-center align-self-center mr-auto"">
                             <h2>{game.Price:F2}&euro;</h2>
                         </div>
                     </div>
                 </div>
             </div>");
     }
 }