Example #1
0
        public HttpResponseMessage Post([FromBody] Bus bus)
        {
            var connectionString = ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString;
            var context = new LunchBusContext(connectionString);

            context.Buses.Create(bus);

            return Request.CreateResponse(HttpStatusCode.Created);
        }
Example #2
0
        public IEnumerable<Bus> GetAsync()
        {
            var connectionStringSetting = ConfigurationManager.ConnectionStrings["StorageConnectionString"];

            if (connectionStringSetting == null)
            {
                throw new ConfigurationErrorsException("No connection string found");
            }

            var connectionString = connectionStringSetting.ConnectionString;
            var context = new LunchBusContext(connectionString);

            var upcomingBuses = context.Buses.GetUpcoming(TimeSpan.FromDays(2));

            return upcomingBuses;
        }