User settings
This commit is contained in:
parent
f2e6045723
commit
b9ba97f5e8
16 changed files with 75 additions and 66 deletions
|
|
@ -11,22 +11,23 @@ namespace Yavsc.Helpers
|
|||
|
||||
public static class WorkflowHelpers
|
||||
{
|
||||
public static List<PerformerProfileViewModel> ListPerformers(this ApplicationDbContext context,
|
||||
public static async Task<List<PerformerProfileViewModel>> ListPerformersAsync(this ApplicationDbContext context,
|
||||
IBillingService billing,
|
||||
string actCode)
|
||||
{
|
||||
var settings = billing.GetPerformersSettingsAsync(actCode).Result?.ToArray();
|
||||
|
||||
var actors = context.Performers
|
||||
.Include(p=>p.Activity)
|
||||
.Include(p=>p.Performer)
|
||||
.Include(p=>p.Performer.Posts)
|
||||
.Include(p=>p.Performer.DeviceDeclaration)
|
||||
.Where(p => p.Active && p.Activity.Any(u=>u.DoesCode==actCode)).OrderBy( x => x.Rate )
|
||||
.ToArray();
|
||||
List<PerformerProfileViewModel> result = new List<PerformerProfileViewModel> ();
|
||||
result.AddRange(
|
||||
actors.Select(a=> new PerformerProfileViewModel(a, actCode, settings?.FirstOrDefault(s => s.UserId == a.PerformerId))));
|
||||
|
||||
List<PerformerProfileViewModel> result = new ();
|
||||
foreach (var a in actors)
|
||||
{
|
||||
var settings = await billing.GetPerformersSettingsAsync(actCode, a.PerformerId);
|
||||
result.Add(new PerformerProfileViewModel(a, actCode,settings));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace Yavsc.Models.Haircut
|
|||
using Relationship;
|
||||
using Calendar;
|
||||
|
||||
public class BrusherProfile : ISpecializationSettings
|
||||
public class BrusherProfile : IUserSettings
|
||||
{
|
||||
public BrusherProfile()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ using System.ComponentModel.DataAnnotations;
|
|||
|
||||
namespace Yavsc.Models.Musical.Profiles
|
||||
{
|
||||
public class DjSettings : ISpecializationSettings
|
||||
public class DjSettings : IUserSettings
|
||||
{
|
||||
|
||||
public string SoundCloudId { get; set; }
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ using System.ComponentModel.DataAnnotations;
|
|||
|
||||
namespace Yavsc.Models.Musical.Profiles
|
||||
{
|
||||
public class GeneralSettings : ISpecializationSettings
|
||||
public class GeneralSettings : IUserSettings
|
||||
{
|
||||
public virtual List<MusicalPreference> SoundColor { get; set; }
|
||||
[Key]
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ using Yavsc.Models.Workflow;
|
|||
|
||||
namespace Yavsc.Models.Musical.Profiles
|
||||
{
|
||||
public class Instrumentation : ISpecializationSettings
|
||||
public class Instrumentation : IUserSettings
|
||||
{
|
||||
public string UserId
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ namespace Yavsc.Models.Workflow.Profiles
|
|||
{
|
||||
using Models.Workflow;
|
||||
using Yavsc;
|
||||
public class FormationSettings : ISpecializationSettings
|
||||
public class FormationSettings : IUserSettings
|
||||
{
|
||||
public virtual List<CoWorking> CoWorking { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -8,15 +8,16 @@ namespace Yavsc.Services
|
|||
public class BillingService : IBillingService
|
||||
{
|
||||
public ApplicationDbContext DbContext { get; private set; }
|
||||
public static Dictionary<string,Func<ApplicationDbContext,long,IDecidableQuery>> Billing =
|
||||
new Dictionary<string,Func<ApplicationDbContext,long,IDecidableQuery>> ();
|
||||
public static Dictionary<string, Func<ApplicationDbContext, long, IDecidableQuery>> Billing =
|
||||
new Dictionary<string, Func<ApplicationDbContext, long, IDecidableQuery>>();
|
||||
public static List<PropertyInfo> UserSettings = new List<PropertyInfo>();
|
||||
|
||||
public static Dictionary<string,string> GlobalBillingMap =
|
||||
new Dictionary<string,string>();
|
||||
|
||||
public Dictionary<string,string> BillingMap {
|
||||
get { return GlobalBillingMap; }
|
||||
public static Dictionary<string, string> GlobalBillingMap =
|
||||
new Dictionary<string, string>();
|
||||
|
||||
public Dictionary<string, string> BillingMap
|
||||
{
|
||||
get { return GlobalBillingMap; }
|
||||
}
|
||||
|
||||
public BillingService(ApplicationDbContext dbContext)
|
||||
|
|
@ -26,23 +27,30 @@ namespace Yavsc.Services
|
|||
|
||||
public Task<IDecidableQuery> GetBillAsync(string billingCode, long queryId)
|
||||
{
|
||||
return Task.FromResult(GetBillable(DbContext,billingCode,queryId));
|
||||
return Task.FromResult(GetBillable(DbContext, billingCode, queryId));
|
||||
}
|
||||
|
||||
public static IDecidableQuery GetBillable(ApplicationDbContext context, string billingCode, long queryId ) => Billing[billingCode](context, queryId);
|
||||
public async Task<ISpecializationSettings> GetPerformerSettingsAsync(string activityCode, string userId)
|
||||
public static IDecidableQuery GetBillable(ApplicationDbContext context, string billingCode, long queryId) => Billing[billingCode](context, queryId);
|
||||
public async Task<IUserSettings> GetPerformersSettingsAsync(string activityCode, string userId)
|
||||
{
|
||||
return (await GetPerformersSettingsAsync(activityCode)).SingleOrDefault(s=> s.UserId == userId);
|
||||
var activity = await DbContext.Activities.SingleAsync(a => a.Code == activityCode);
|
||||
|
||||
if (activity.SettingsClassName == null) return null;
|
||||
|
||||
var dbSetGetter =
|
||||
UserSettings.SingleOrDefault(s => s.Name == activity.SettingsClassName);
|
||||
|
||||
if (dbSetGetter==null) return null;
|
||||
var dbSet = dbSetGetter.GetValue(DbContext);
|
||||
|
||||
if (dbSet == null) return null;
|
||||
|
||||
if (dbSet is DbSet<IUserSettings> userSettings)
|
||||
{
|
||||
return userSettings.FirstOrDefault(s => s.UserId == userId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ISpecializationSettings>> GetPerformersSettingsAsync(string activityCode)
|
||||
{
|
||||
var activity = await DbContext.Activities.SingleAsync(a=>a.Code == activityCode);
|
||||
|
||||
if (activity.SettingsClassName==null) return null;
|
||||
|
||||
return UserSettings.Where(s => s.PropertyType.GenericTypeArguments[0].FullName == activity.SettingsClassName)
|
||||
.Cast<ISpecializationSettings>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,6 @@ namespace Yavsc.ViewModels.Workflow
|
|||
{
|
||||
public UserActivity Declaration { get; set; }
|
||||
public bool NeedsSettings { get; set; }
|
||||
public ISpecializationSettings Settings { get; set; }
|
||||
public IUserSettings Settings { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue