yavsc/src/Yavsc/Helpers/WorkflowHelpers.cs

35 lines
1.1 KiB
C#
Raw Normal View History

2017-01-31 13:19:12 +01:00
namespace Yavsc.Helpers
{
2017-02-03 15:25:47 +01:00
using System.Collections.Generic;
using System.Linq;
using Microsoft.Data.Entity;
using Yavsc.Models;
2018-06-15 15:44:21 +02:00
using Yavsc.Services;
using Yavsc.ViewModels.FrontOffice;
public static class WorkflowHelpers
{
2018-06-15 15:44:21 +02:00
public static List<PerformerProfileViewModel> ListPerformers(this ApplicationDbContext context,
IBillingService billing,
string actCode)
2017-02-03 15:25:47 +01:00
{
2018-06-15 15:44:21 +02:00
var settings = billing.GetPerformersSettingsAsync(actCode).Result?.ToArray();
var actors = context.Performers
2017-02-03 15:25:47 +01:00
.Include(p=>p.Activity)
.Include(p=>p.Performer)
.Include(p=>p.Performer.Posts)
2019-05-24 20:17:24 +01:00
.Include(p=>p.Performer.DeviceDeclaration)
2018-06-15 15:44:21 +02:00
.Where(p => p.Active && p.Activity.Any(u=>u.DoesCode==actCode)).OrderBy( x => x.Rate )
.ToArray();
2019-08-20 16:49:38 +01:00
List<PerformerProfileViewModel> result = new List<PerformerProfileViewModel> ();
result.AddRange(
actors.Select(a=> new PerformerProfileViewModel(a, actCode, settings?.FirstOrDefault(s => s.UserId == a.PerformerId))));
2018-06-15 15:44:21 +02:00
2019-08-20 16:49:38 +01:00
return result;
2017-02-03 15:25:47 +01:00
}
2017-05-12 16:29:47 +02:00
}
2017-05-12 16:29:47 +02:00
}