TireTargetsWeb/Components/Pages/Home.razor.cs

65 lines
2.0 KiB
C#
Raw Normal View History

2025-07-21 14:01:24 -04:00
using Telerik.Blazor.Components;
namespace TireTargets.Components.Pages
{
public partial class Home
{
private List<(string, string)> availableTireOffers = new List<(string, string)>();
private List<(string, string)> availableServiceOffers = new List<(string, string)>();
private List<CarouselModel> TireOffers { get; set; } = new List<CarouselModel>();
private List<CarouselModel> ServiceOffers { get; set; } = new List<CarouselModel>();
public int PageIndex = 1;
protected override void OnInitialized()
{
if (availableTireOffers.Count == 0)
{
// TODO: switch to read from server instead of local dir
string[] files = Directory.GetFiles(@"wwwroot\assets\TestTireDir");
foreach (var file in files)
{
availableTireOffers.Add((file.Substring(8), file.Substring(8)));
}
files = Directory.GetFiles(@"wwwroot\assets\TestServiceDir");
foreach (var file in files)
{
availableServiceOffers.Add((file.Substring(8), file.Substring(8)));
}
}
// Add the fetched offers to the Carousel
foreach ((string, string) current in availableTireOffers)
{
TireOffers.Add(new CarouselModel(current.Item2));
}
foreach ((string, string) current in availableServiceOffers)
{
ServiceOffers.Add(new CarouselModel(current.Item2));
}
//Console.WriteLine(String.Join(", ", TireOffers.);
}
public async Task PageChangeHandler(int newPage)
{
PageIndex = newPage;
}
public class CarouselModel
{
public CarouselModel(string filePath)
{
ImageID = filePath;
}
public string ImageID { get; set; }
}
}
}