示例#1
0
        public IActionResult Post(Reservation reservations)
        {
            try
            {
                if (SystemStatus.RsvSvc == true)
                {
                    long sDay = ((DateTimeOffset)DateTime.Today).ToUnixTimeSeconds();
                    long eDay = ((DateTimeOffset)DateTime.Today.AddDays(1)).ToUnixTimeSeconds();

                    if (reservations.StartTime > sDay && reservations.EndTime < eDay)
                    {
                        if (reserve.BookRoomNow(reservations))
                        {
                            return(Ok("Direct booking created!"));
                        }
                        else
                        {
                            return(BadRequest("Failed to create booking! please check and try again."));
                        }
                    }
                    return(Conflict("Cannot create direct booking! (Only for booking today)"));
                }
                return(Conflict("Cannot create direct booking! (Reservation service is not started)"));
            } catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }