chore: add fake data source for admin carousel
This commit is contained in:
parent
2550d6bbf7
commit
a1de19e22f
|
@ -1,14 +1,20 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using pwt_0x01_ng.Models;
|
||||
using pwt_0x01_ng.Models.Dbfake;
|
||||
|
||||
namespace pwt_0x01_ng.Areas.Admin.Controllers
|
||||
{
|
||||
[Area("Admin")]
|
||||
public class Carousel : Controller
|
||||
public class CarouselController : Controller
|
||||
{
|
||||
private IList<Carousel> Carousels = Dbfake.Carousels;
|
||||
// GET
|
||||
public IActionResult Select()
|
||||
{
|
||||
return View();
|
||||
CarouselViewModel carousel = new CarouselViewModel();
|
||||
carousel.Carousels = Carousels;
|
||||
return View(carousel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
@model CarouselViewModel
|
||||
@{
|
||||
ViewData["Title"] = "Carousel Select";
|
||||
}
|
||||
|
@ -5,3 +6,30 @@
|
|||
<h3>@ViewData["Message"]</h3>
|
||||
|
||||
<p>Select all data from carousel.</p>
|
||||
|
||||
@{
|
||||
if (Model?.Carousels != null && Model.Carousels.Count > 0) {
|
||||
<table style="width:100%">
|
||||
<tr>
|
||||
<th>First name</th>
|
||||
<th>Last name</th>
|
||||
<th>Age</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>fnksnjksd</td>
|
||||
<td>mvdnskjr</td>
|
||||
<td>8797321</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>jfdsjfds</td>
|
||||
<td>nkjfdndf</td>
|
||||
<td>645</td>
|
||||
</tr>
|
||||
</table>
|
||||
}
|
||||
else
|
||||
{
|
||||
<h2>Carousel is empty</h2>
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
@using pwt_0x01_ng
|
||||
@using pwt_0x01_ng.Models
|
||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
@{
|
||||
Layout = "_Layout";
|
||||
}
|
|
@ -5,18 +5,19 @@ using System.Linq;
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using pwt_0x01_ng.Models;
|
||||
using pwt_0x01_ng.Models.Dbfake;
|
||||
|
||||
namespace pwt_0x01_ng.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private IList<Carousel> carousels = CarouselHelper.GenerateCarousel();
|
||||
private IList<Carousel> carousels = Dbfake.Carousels;
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
var vm = new CarouselViewModel();
|
||||
vm.Carousels = carousels;
|
||||
return View(vm);
|
||||
CarouselViewModel carousel = new CarouselViewModel();
|
||||
carousel.Carousels = carousels;
|
||||
return View(carousel);
|
||||
}
|
||||
|
||||
public IActionResult About()
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
|
||||
namespace pwt_0x01_ng.Models
|
||||
namespace pwt_0x01_ng.Models.Dbfake
|
||||
{
|
||||
public static class CarouselHelper
|
||||
{
|
|
@ -0,0 +1,15 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace pwt_0x01_ng.Models.Dbfake
|
||||
{
|
||||
public static class Dbfake
|
||||
{
|
||||
/* singe db table simulation*/
|
||||
public static IList<Carousel> Carousels { get; set; }
|
||||
|
||||
static Dbfake()
|
||||
{
|
||||
Carousels = CarouselHelper.GenerateCarousel();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue