booking api: performers
This commit is contained in:
24
Yavsc/ApiControllers/FrontOfficeApiController.cs
Normal file
24
Yavsc/ApiControllers/FrontOfficeApiController.cs
Normal file
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user