Esempio n. 1
0
        public static async Task <string> GetEvent([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "getEvent")] HttpRequest req, ILogger log)
        {
            try {
                List <string> output = CRUDHelper.getQuery(
                    String.Format(
                        "SELECT name, startDate, description FROM modestomovesdb.raceEvents WHERE nameID = '{0}'",
                        req.Query["name"]
                        )
                    );
                string is_ongoing = "false";

                var          utc         = DateTime.UtcNow;
                TimeZoneInfo pacificZone = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");
                var          pacificTime = TimeZoneInfo.ConvertTimeFromUtc(utc, pacificZone);

                var format     = "yyyy-MM-dd";
                var stringDate = pacificTime.ToString(format);

                DateTime date_time     = DateTime.Parse(output[0].Split(",") [1]);
                string   formattedDate = date_time.ToString(format);

                if (formattedDate == stringDate)
                {
                    is_ongoing = "true";
                }
                return(String.Format(  //Generate the member object
                           "{{{0}, \"is_ongoing\": \"{1}\" }}",
                           CRUDHelper.formatEvent(output[0].Split(",")),
                           is_ongoing
                           ));
            } catch (Exception ex) {
                return(ex.ToString());
            }
        }
Esempio n. 2
0
 public static async Task <string> GetCalendarEvents([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "getCalendarEvents")] HttpRequest req, ILogger log)
 {
     try {
         return(String.Format(  //Generate the member object
                    "{{'events' : [{0}]}}".Replace("'", "\""),
                    String.Join(
                        ",",
                        CRUDHelper.getQuery(
                            "SELECT name, startDate, description FROM modestomovesdb.raceEvents"
                            ).Select(
                            x => "{" + CRUDHelper.formatEvent(x.Split(',')) + "}"
                            ).ToArray()
                        )
                    ));
     } catch (Exception ex) {
         return(ex.ToString());
     }
 }