Skip to content

Commit

Permalink
MVP for listing works by specific artist
Browse files Browse the repository at this point in the history
  • Loading branch information
czf committed Jan 16, 2021
1 parent 892582b commit be19fca
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,10 @@ public async Task<ArtistWorkInfo> GetArtistWork(int id)
{
return await Task.FromResult(GetArtistWorks().First(x => x.Id == id));
}

public async Task<IEnumerable<ArtistWorkInfo>> GetArtist_ArtistWorks(int artistId)
{
return await Task.FromResult( GetArtistWorks().Where(x => x.ArtistInfo.Id == artistId));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public interface IRadiocomArtistWorkRepository
{
IEnumerable<ArtistWorkInfo> GetArtistWorks();
IEnumerable<ArtistWorkInfo> GetArtistWorks(char alphaFilter);
Task<IEnumerable<ArtistWorkInfo>> GetArtist_ArtistWorks(int artistId);
Task<ArtistWorkInfo> GetArtistWork(int id);

}
Expand Down
33 changes: 33 additions & 0 deletions RadiocomDataViewApp/Objects/ArtistWorkDisplay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using RadiocomDataViewApp.Interfaces;
using RadiocomDataViewApp.Objects.Dto;

namespace RadiocomDataViewApp.Objects
{
public class ArtistWorkDisplay : IHasName
{
private ArtistWorkInfo _artistWorkInfo;

public ArtistWorkDisplay(ArtistWorkInfo artistWorkInfo)
{
_artistWorkInfo = artistWorkInfo;
}

public string Name
{
get => FormatDisplayName(_artistWorkInfo);
set => _artistWorkInfo.Name = value;
}
public int Id
{
get => _artistWorkInfo.Id;
set => _artistWorkInfo.Id = value;
}

private static string FormatDisplayName(ArtistWorkInfo artistWorkInfo)
=> $"{artistWorkInfo.Name} ({artistWorkInfo.ArtistInfo.Name})";
}
}
31 changes: 0 additions & 31 deletions RadiocomDataViewApp/Pages/ArtistWork.razor
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,3 @@
<SongPercentageOfArtistPieChart ArtistWorkId="@ArtistWorkId" ArtistName="@ArtistName" ArtistId="@ArtistId" />
</Column>
</Row>

@using RadiocomDataViewApp.Clients;
@code{

//Clients.AggregateTimeRange ChartDataTimeRange = Clients.AggregateTimeRange.SevenDays;
//private IEnumerable<DashboardChartData> SongPlayedOverTime()
//{
// List<ItemCount> radioComData = RadiocomDataAggregateDataClient.GetSongPlayedOverTime(ChartDataTimeRange,ArtistWorkId);
// return radioComData.Select(x => new DashboardChartData() { Label = x.Name, Value = x.Count, DataId = x.ItemId });
//}
//private List<HeaderButtonState> HeaderButtonConfigs { get; set; }
//private void SetupHeaderButtons()
//{
// HeaderButtonConfigs = new List<HeaderButtonState>()
// {
// new HeaderButtonState(){Text = "7 Days",ButtonColor=Color.Secondary,Active=true, ButtonClickCallback = EventCallback.Factory.Create(this, () => UpdateChartDataTimeRange(AggregateTimeRange.SevenDays)) } ,
// new HeaderButtonState(){Text = "3 Months", ButtonClickCallback = EventCallback.Factory.Create(this, () => UpdateChartDataTimeRange(AggregateTimeRange.ThreeMonths)) } ,
// new HeaderButtonState(){Text = "All Time", ButtonClickCallback = EventCallback.Factory.Create(this, () => UpdateChartDataTimeRange(AggregateTimeRange.AllTime)) }
// };
// ChartDataTimeRange = AggregateTimeRange.SevenDays;
//}
//private DashboardLineGraphChartComponent Chart;
//private void UpdateChartDataTimeRange(AggregateTimeRange mostPlayedTimeRange)
//{
// ChartDataTimeRange = mostPlayedTimeRange;
// Chart.RefreshChartData();
//}
}
24 changes: 1 addition & 23 deletions RadiocomDataViewApp/Pages/ArtistWorks.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,6 @@ public partial class ArtistWorks : ComponentBase
Func<ArtistWorkDisplay, string> HrefGenerator = item => $"artistwork/{item.Id}";


private class ArtistWorkDisplay : IHasName
{
private ArtistWorkInfo _artistWorkInfo;

public ArtistWorkDisplay(ArtistWorkInfo artistWorkInfo)
{
_artistWorkInfo = artistWorkInfo;
}

public string Name
{
get => FormatDisplayName(_artistWorkInfo);
set => _artistWorkInfo.Name = value;
}
public int Id
{
get => _artistWorkInfo.Id;
set => _artistWorkInfo.Id = value;
}

private static string FormatDisplayName(ArtistWorkInfo artistWorkInfo)
=> $"{artistWorkInfo.Name} ({artistWorkInfo.ArtistInfo.Name})";
}

}
}
4 changes: 4 additions & 0 deletions RadiocomDataViewApp/Pages/Artist_ArtistsWorksList.razor
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
@page "/artist/{ArtistId:int}/artistworks"
@{
}
<h3>All Songs by @_artistName</h3>


<ListComponent TItem="ArtistWorkDisplay" Items="@_artistWorkInfos.Select(x=> new ArtistWorkDisplay(x)).OrderBy(x => x.Name)" ListItemHrefGenerator="HrefGenerator" />
14 changes: 13 additions & 1 deletion RadiocomDataViewApp/Pages/Artist_ArtistsWorksList.razor.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
Expand All @@ -6,13 +7,24 @@
using RadiocomDataViewApp.Clients;
using RadiocomDataViewApp.Interfaces;
using RadiocomDataViewApp.Objects;
using RadiocomDataViewApp.Objects.Dto;

namespace RadiocomDataViewApp.Pages
{
public partial class Artist_ArtistsWorksList : ComponentBase
{
[Inject]
public IRadiocomArtistWorkRepository RadiocomArtistWorkRepository { get; set; }
[Parameter]
public int ArtistId { get; set; }

private string _artistName;
private static readonly Func<ArtistWorkDisplay, string> HrefGenerator = item => $"artistwork/{item.Id}";
private IEnumerable<ArtistWorkInfo> _artistWorkInfos;
protected override async Task OnParametersSetAsync()
{
await base.OnParametersSetAsync();
_artistWorkInfos = await RadiocomArtistWorkRepository.GetArtist_ArtistWorks(ArtistId);
_artistName = _artistWorkInfos.FirstOrDefault()?.ArtistInfo.Name;
}
}
}

0 comments on commit be19fca

Please sign in to comment.