using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using RMuseum.DbContext;
using RMuseum.Models.MusicCatalogue;
using RMuseum.Models.MusicCatalogue.ViewModels;
using RSecurityBackend.Models.Generic;
using RSecurityBackend.Models.Generic.Db;
using RSecurityBackend.Services.Implementation;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
namespace RMuseum.Services.Implementation
{
///
/// Music Catalgue Service Implementation
///
public class MusicCatalogueService : IMusicCatalogueService
{
///
/// get golha collection programs
///
///
///
public async Task> GetGolhaCollectionPrograms(int id)
{
return new RServiceResult
(
await _context.GolhaPrograms.Where(p => p.GolhaCollectionId == id).OrderBy(p => p.Id)
.Select(p => new GolhaProgramViewModel()
{
Id = p.Id,
Title = p.Title,
Url = p.Url,
ProgramOrder = p.ProgramOrder,
Mp3 = p.Mp3
}).ToArrayAsync()
);
}
///
/// get golha program tracks
///
///
///
public async Task> GetGolhaProgramTracks(int id)
{
return new RServiceResult
(
await _context.GolhaTracks.Where(p => p.GolhaProgramId == id).OrderBy(p => p.Id)
.Select(p => new GolhaTrackViewModel()
{
Id = p.Id,
TrackNo = p.TrackNo,
Timing = p.Timing,
Title = p.Title,
}).ToArrayAsync()
); ;
}
///
/// Configuration
///
protected IConfiguration Configuration { get; }
///
/// Database Contetxt
///
protected readonly RMuseumDbContext _context;
///
/// constructor
///
///
///
public MusicCatalogueService(IConfiguration configuration, RMuseumDbContext context)
{
Configuration = configuration;
_context = context;
}
}
}