示例#1
0
        public IHttpActionResult DeleteSlotsByYear(int year)
        {
            RSR sr;

            sr = RwpSlots.ClearYear(year);
            return(Ok(sr));
        }
示例#2
0
        public IHttpActionResult DeleteAllSlots()
        {
            RSR sr;

            sr = RwpSlots.ClearAll();
            return(Ok(sr));
        }
示例#3
0
            [TestCase("3/18/2017", "07:30:00 PM", "Sun, 19 Mar 2017 02:30:00 GMT")] // after PDT
            public static void TestStartTimeFromDateAndTime(string sStartDate, string sTime, string sExpected)
            {
                DateTime dttmStart  = DateTime.Parse(sStartDate);
                DateTime dttmActual = RwpSlots.StartTimeFromDateAndTime(dttmStart, sTime);

                Assert.AreEqual(sExpected, dttmActual.ToString("r"));
            }
示例#4
0
        public Stream GetCsvSlots()
        {
            Stream stm = new MemoryStream(4096);

            RwpSlots slots = new RwpSlots();

            slots.GetCsv(stm);
            stm.Flush();
            stm.Seek(0, SeekOrigin.Begin);
            return(stm);
        }
示例#5
0
            public static RSR_CalItems GetCalendarItemsForTeam(string sTeam)
            {
                SqlWhere     sw = new SqlWhere();
                RSR          rsr;
                RSR_CalItems rci;
                RwpSlots     slots = new RwpSlots();

                sw.AddAliases(RwpSlot.s_mpAliases);
                try
                {
                    sw.Add(String.Format("$$rwllpractice$$.Reserved = '{0}'", Sql.Sqlify(sTeam)), SqlWhere.Op.And);

                    rsr = RSR.FromSR(Sql.ExecuteQuery(null, sw.GetWhere(RwpSlot.s_sSqlQueryString), slots, _sResourceConnString));

                    if (!rsr.Succeeded)
                    {
                        rci        = RSR_CalItems.FromRSR(rsr);
                        rci.Reason = String.Format("{0} {1}", rci.Reason, _sResourceConnString);
                        return(rci);
                    }

                    rci = RSR_CalItems.FromRSR(RSR.FromSR(SR.Success()));

                    List <CalItem> plci = new List <CalItem>();

                    if (slots.Slots != null)
                    {
                        foreach (RwpSlot slot in slots.Slots)
                        {
                            CalItem ci = new CalItem();

                            ci.Start       = StartTimeFromDateAndTime(slot.SlotDate, slot.StartTime);
                            ci.End         = StartTimeFromDateAndTime(slot.SlotDate, slot.EndTime);
                            ci.Location    = String.Format("{0}: {1}", slot.Venue, slot.Field);
                            ci.Title       = String.Format("Team Practice: {0}", slot.Reserved);
                            ci.Description = String.Format("Redmond West Little League team practice at {0} ({1}), for team {2}", slot.Venue, slot.Field, slot.Reserved);
                            ci.UID         = String.Format("{0}-rwllpractice-{1}", slot.Slot, slot.SlotDate.ToString("yyyyMMdd"));
                            plci.Add(ci);
                        }
                    }
                    rci.TheValue = plci;
                    return(rci);
                }
                catch (Exception e)
                {
                    rci        = RSR_CalItems.FromRSR(RSR.Failed(e));
                    rci.Reason = String.Format("{0} ({1})", rci.Reason, sTeam);
                    return(rci);
                }
            }
示例#6
0
        public IHttpActionResult PutSlots(HttpRequestMessage request)
        {
            string TimeZoneID = "Pacific Standard Time";

            Task <Stream> stm = request.Content.ReadAsStreamAsync();

            // need to figure out how to pass this as a parameter
            TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById(TimeZoneID);

            if (tzi == null)
            {
                throw new Exception($"cannot load timezone {TimeZoneID}");
            }

            stm.Wait();

            RSR sr;

            sr = RwpSlots.ImportCsv(stm.Result, tzi);
            return(Ok(sr));
        }
示例#7
0
        public HttpResponseMessage GetSlots(string TimeZoneID)
        {
            Stream stm = new MemoryStream(4096);

            RwpSlots slots = new RwpSlots();

            TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById(TimeZoneID);

            if (tzi == null)
            {
                throw new Exception($"cannot load timezone {TimeZoneID}");
            }

            slots.GetCsv(stm, tzi);
            stm.Flush();
            stm.Seek(0, SeekOrigin.Begin);

            HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);

            result.Content = new StreamContent(stm);
            result.Content.Headers.ContentType =
                new MediaTypeHeaderValue("application/octet-stream");
            return(result);
        }
示例#8
0
        public IHttpActionResult GetCalendarForTeam(string linkID)
        {
            RSR_CalItems items = RwpSlots.GetCalendarItemsForTeam(linkID);

            return(Ok(items));
        }
示例#9
0
 public RSR ClearYear(int nYear)
 {
     return(RwpSlots.ClearYear(nYear));
 }
示例#10
0
 public RSR ClearSlots()
 {
     return(RwpSlots.ClearAll());
 }
示例#11
0
 public RSR ImportCsvSlots(Stream stmCsv)
 {
     return(RwpSlots.ImportCsv(stmCsv));
 }
示例#12
0
 public RSR_CalItems GetCalendarForTeam(string sTeamName)
 {
     return(RwpSlots.GetCalendarItemsForTeam(sTeamName));
 }