// Create a new Session
        // POST /api/session
        public HttpResponseMessage Post(Session session)
        {
            Uow.Sessions.Add(session);
            Uow.Commit();

            var response = Request.CreateResponse(HttpStatusCode.Created, session);

            // Compose location header that tells how to get this session
            // e.g. ~/api/session/5
            response.Headers.Location =
                new Uri(Url.Link(RouteConfig.ControllerAndId, new { id = session.Id }));

            return response;
        }
Ejemplo n.º 2
0
 private static void EnsureTimeSlotIdIsFree(List<int> usedAttendeeSlots, Session session, Func<int> getNextTimeSlotId)
 {
     var origSlot = session.TimeSlotId;
     var slot = origSlot;
     while (usedAttendeeSlots.Contains(slot))
     {
         slot = getNextTimeSlotId();
         if (origSlot == slot) return; // couldn't find a free slot
         session.TimeSlotId = slot;
     }
     usedAttendeeSlots.Add(slot); // used a free slot
 }
 // Update an existing Session
 // PUT /api/sessions/
 public HttpResponseMessage Put(Session session)
 {
     Uow.Sessions.Update(session);
     Uow.Commit();
     return new HttpResponseMessage(HttpStatusCode.NoContent);
 }