booking api: performers

vnext
Paul Schneider 8 years ago
parent 8a4a778322
commit 21ec2f40b3
2 changed files with 38 additions and 0 deletions

@ -0,0 +1,24 @@
using System.Collections.Generic;
using Microsoft.AspNet.Mvc;
using Yavsc.Helpers;
using Yavsc.Models;
using Yavsc.Models.Workflow;
namespace Yavsc.ApiControllers
{
[Route("api/front")]
public class FrontOfficeApiController: Controller
{
ApplicationDbContext dbContext;
public FrontOfficeApiController(ApplicationDbContext context)
{
dbContext = context;
}
[HttpGet,Route("Book/{actCode}")]
IEnumerable<PerformerProfile> Book (string actCode)
{
return dbContext.ListPerformers(actCode);
}
}
}

@ -2,7 +2,11 @@
namespace Yavsc.Helpers
{
using System.Collections.Generic;
using System.Linq;
using Microsoft.Data.Entity;
using Models.Workflow;
using Yavsc.Models;
using YavscLib;
public static class WorkflowHelpers
{
@ -12,5 +16,15 @@ namespace Yavsc.Helpers
if (ctor==null) return null;
return (ISpecializationSettings) ctor.Invoke(null);
}
public static List<PerformerProfile> ListPerformers(this ApplicationDbContext context, string actCode)
{
return context.Performers
.Include(p=>p.Activity)
.Include(p=>p.Performer)
.Include(p=>p.Performer.Posts)
.Include(p=>p.Performer.Devices)
.Where(p => p.Active && p.Activity.Any(u=>u.DoesCode==actCode)).OrderBy( x => x.Rate ).ToList();
}
}
}
Loading…