예제 #1
0
        public HttpResponseMessage GetRegisteredSchools()
        {
            List<School> _schools = null;
            using (var context = new uzoneEntities())
            {
                _schools = (from s in context.Schools
                            select s).ToList();

                if (_schools.Count == 0)
                    return Request.CreateResponse(HttpStatusCode.NotFound);

                return Request.CreateResponse(HttpStatusCode.OK, new { _schools });
            }
        }
예제 #2
0
        public HttpResponseMessage GetSchoolCurrentEvents([FromUri] string schoolID)
        {
            long sID = Convert.ToInt64(schoolID);
            int currentMonth = DateTime.Now.Month;
            using (var context = new uzoneEntities())
            {
                var result = (from s in context.Schedulers
                              where s.SchoolID == sID &&
                              s.EventStart.Value.Month == currentMonth &&
                              s.EventStart.Value.Year == DateTime.Now.Year &&
                              s.EventStart >= DateTime.Now
                              orderby s.EventStart
                              select new SchedulerFormatted()
                              {
                                  SchedulerID = s.SchedulerID,
                                  SchoolID = s.SchoolID,
                                  EventDescription = s.EventDescription,
                                  EventSubject = s.EventSubject,
                                  EventLocationID = s.EventLocationID
                              })
                             .ToList()
                             .Select(x => new SchedulerFormatted()
                             {
                                 SchedulerID = x.SchedulerID,
                                 SchoolID = x.SchoolID,
                                 EventStart = string.Format("{0:MMMM d, yyyy H:mm}", x.EventStart),
                                 EventEnd = string.Format("{0:MMMM d, yyyy H:mm}", x.EventEnd),
                                 EventDescription = x.EventDescription,
                                 EventSubject = x.EventSubject,
                                 EventLocationID = x.EventLocationID,
                                 EventStartFormatted = string.Format("{0:dddd, MMMM d, yyyy}", x.EventStart)
                             });

                if (!result.Any())
                   return Request.CreateResponse(HttpStatusCode.NotFound);

                return Request.CreateResponse(HttpStatusCode.OK, result);
            }
        }