/
LookupsController.cs
60 lines (53 loc) · 1.61 KB
/
LookupsController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
using CodeCamper.Data.Contracts;
using CodeCamper.Model;
namespace CodeCamper.Web.Controllers
{
public class LookupsController : ApiControllerBase
{
public LookupsController(ICodeCamperUow uow)
{
Uow = uow;
}
// GET: api/lookups/rooms
[ActionName("rooms")]
public IEnumerable<Room> GetRooms()
{
return Uow.Rooms.GetAll().OrderBy(r => r.Name);
}
// GET: api/lookups/timeslots
[ActionName("timeslots")]
public IEnumerable<TimeSlot> GetTimeSlots()
{
return Uow.TimeSlots.GetAll().OrderBy(ts => ts.Start);
}
// GET: api/lookups/tracks
[ActionName("tracks")]
public IEnumerable<Track> GetTracks()
{
return Uow.Tracks.GetAll().OrderBy(t => t.Name);
}
// Lookups: aggregates the many little lookup lists in one payload
// to reduce roundtrips when the client launches.
// GET: api/lookups
[ActionName("all")]
public Lookups GetLookups()
{
var lookups = new Lookups
{
Rooms = GetRooms().ToList(),
TimeSlots = GetTimeSlots().ToList(),
Tracks = GetTracks().ToList(),
};
return lookups;
}
#region OData Future: IQueryable<T>
//[Queryable]
// public IQueryable<Room> Get()
// public IQueryable<TimeSlot> Get()
// public IQueryable<Track> Get()
#endregion
}
}