yavsc/Yavsc/Helpers/WorkflowHelpers.cs

38 lines
1.2 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)
.Include(p=>p.Performer.Devices)
2018-06-15 15:44:21 +02:00
.Where(p => p.Active && p.Activity.Any(u=>u.DoesCode==actCode)).OrderBy( x => x.Rate )
.ToArray();
List<PerformerProfileViewModel> result = new List<PerformerProfileViewModel> ();
foreach (var perfer in actors)
{
var view = new PerformerProfileViewModel(perfer, actCode, settings?.FirstOrDefault(s => s.UserId == perfer.PerformerId));
result.Add(view);
}
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
}