Exemplo n.º 1
0
        // POST: api/Schedule
        public HttpResponseMessage Post([FromBody] Schedule schedule)
        {
            SchedulePersistence sp = new SchedulePersistence();
            int id = sp.CreateNewSchedule(schedule);
            HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.Created);

            response.Headers.Location = new Uri(Request.RequestUri, string.Format($"Schedule/{id}"));
            return(response);
        }
Exemplo n.º 2
0
        // GET: api/Schedule/5
        public Schedule Get(int id)
        {
            SchedulePersistence sp = new SchedulePersistence();

            if (sp.GetSchedule(id) == null)
            {
                throw new  HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound));
            }
            return(sp.GetSchedule(id));
        }
Exemplo n.º 3
0
        //GET:api/schedule?date=01%2F01%2F2018
        public List <Schedule> Get(string date)
        {
            SchedulePersistence sp = new SchedulePersistence();

            if (sp.GetSchedules(date) == null)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound));
            }
            return(sp.GetSchedules(date));
        }
Exemplo n.º 4
0
        // DELETE: api/Schedule/5
        public HttpResponseMessage Delete(int id)
        {
            SchedulePersistence sp = new SchedulePersistence();
            bool isInSchedule      = false;
            HttpResponseMessage response;

            isInSchedule = sp.DeleteSchedule(id);
            if (isInSchedule)
            {
                response = Request.CreateResponse(HttpStatusCode.NoContent);
            }
            else
            {
                response = Request.CreateResponse(HttpStatusCode.NotFound);
            }

            return(response);
        }
Exemplo n.º 5
0
        // PUT: api/Schedule/5
        public HttpResponseMessage Put(int id, [FromBody] Schedule schedule)
        {
            SchedulePersistence sp = new SchedulePersistence();
            bool isInSchedules     = false;
            HttpResponseMessage response;

            isInSchedules = sp.UpdateSchedule(id, schedule);
            if (isInSchedules)
            {
                response = Request.CreateResponse(HttpStatusCode.NoContent);
            }
            else
            {
                response = Request.CreateResponse(HttpStatusCode.NotFound);
            }

            return(response);
        }
Exemplo n.º 6
0
        //GET: api/Schedule
        public List <Schedule> Get()
        {
            SchedulePersistence sp = new SchedulePersistence();

            return(sp.GetSchedules());
        }
Exemplo n.º 7
0
 public SchedulesController(HttpListenerContext context) : base(context)
 {
     _schedulePersistence = new SchedulePersistence();
     _roomPersistence     = new RoomPersistence();
     _moviePersistence    = new MoviePersistence();
 }
Exemplo n.º 8
0
 public BookingController(HttpListenerContext context) : base(context)
 {
     _schedulePersistence = new SchedulePersistence();
     _userPersistence     = new UserPersistence();
     _bookingPersistence  = new BookingPersistence();
 }