Пример #1
0
        public ActionResult <IEnumerable <Availability> > GetAvailabilityTimeFilter(
            [FromBody] FromToTime fromToTime
            )
        {
            List <Availability> availabilityList;

            if (fromToTime.From >= fromToTime.To)
            {
                var response = new HttpResponseMessage(HttpStatusCode.BadRequest);
                response.ReasonPhrase = "Request unsuccesful";
                return(NotFound("'To' value must be higher than 'From' value"));
            }



            using (MySqlConnection con = new MySqlConnection(_connectionString.MySQL))
            {
                var output = con.Query <Availability>("CALL SpGetAvailabilityTableByTime(" +
                                                      String.Format("{0}, ", ParseDateToMySqlTimestampFunc(fromToTime.From)) +
                                                      String.Format("{0});", ParseDateToMySqlTimestampFunc(fromToTime.To)));

                availabilityList = output.AsList();
            }

            if (availabilityList.Count != 0)
            {
                return(Ok(availabilityList));
            }
            else
            {
                var response = new HttpResponseMessage(HttpStatusCode.NotFound);
                response.ReasonPhrase = "Request unsuccesful";
                return(NotFound("Procedure call did not return a value"));
            }
        }
Пример #2
0
 public async Task CreateBookable_NormalRollingBookableValidData_ShouldCallHandler()
 {
     Bookable expectedBookable = new()
     {
         Id           = Guid.Empty,
         Name         = "Test name",
         From         = ApplicationTime.UtcNow(),
         To           = DateTime.MaxValue,
         DaysAndTimes = new List <DayAndTimes>()
         {
             new()
             {
                 Day  = DayOfWeek.Monday,
                 Time = new FromToTime
                 {
                     From = new Time
                     {
                         Hour   = 10,
                         Minute = 0,
                     },
                     To = new Time
                     {
                         Hour   = 18,
                         Minute = 0,
                     },
                 },
                 NonBookableTime = new FromToTime
                 {
                     From = new Time
                     {
                         Hour   = 13,
                         Minute = 0,
                     },
                     To = new Time
                     {
                         Hour   = 13,
                         Minute = 30,
                     },
                 }
             },
         },
         Foresight       = 24,
         StartInterval   = StartInterval.Fifteen,
         NonBookableDays = null,
     };