public IActionResult GetAllAvailabilityReservations(
            [HttpTrigger(AuthorizationLevel.Function, "get", Route = "ReservationFunctionApi/Availability")] HttpRequestMessage req, ExecutionContext context)
        {
            /*Validate JWT*/
            if ((SecurityJwt.ValidateToken(req.Headers.Authorization, context.FunctionAppDirectory)) == null)
            {
                return(new UnauthorizedResult());
            }
            /*Code*/
            var            query          = System.Web.HttpUtility.ParseQueryString(req.RequestUri.Query);
            string         result         = query.Get("result");
            ReservationDto reservationDto = new ReservationDto()
            {
                IdEmployee = Convert.ToInt32(query.Get("idEmployee")),
                IdService  = Convert.ToInt32(query.Get("idService")),
                IdUser     = Convert.ToInt32(query.Get("idUser")),
                Date       = Convert.ToDateTime(query.Get("dateTime"))
            };
            Services  service  = dbServiceOperations.GetByPk(reservationDto.IdService);
            Employees employee = dbEmployeeOperations.GetByPk(reservationDto.IdEmployee);

            reservationDto.IdEmployeeNavigation = _mapper.Map <Employees, EmployeeDto>(employee);
            reservationDto.IdServiceNavigation  = _mapper.Map <Services, ServiceDto>(service);

            List <ReservationDto> responseMessage = GetAvailability(reservationDto);

            return(new OkObjectResult(responseMessage));
        }
        public IActionResult GetReservation(
            [HttpTrigger(AuthorizationLevel.Function, "get", Route = "ReservationFunctionApi/{id:int}")] HttpRequestMessage req, int id, ExecutionContext context)
        {
            /*Validate JWT*/
            if ((SecurityJwt.ValidateToken(req.Headers.Authorization, context.FunctionAppDirectory)) == null)
            {
                return(new UnauthorizedResult());
            }
            /*Code*/
            var            result          = db.GetByPk(id);
            ReservationDto responseMessage = _mapper.Map <Reservations, ReservationDto>(result);

            return(new OkObjectResult(responseMessage));
        }
        public IActionResult GetReservations(
            [HttpTrigger(AuthorizationLevel.Function, "get", Route = "ReservationFunctionApi")] HttpRequestMessage req, ExecutionContext context)
        {
            /*Validate JWT*/
            if ((SecurityJwt.ValidateToken(req.Headers.Authorization, context.FunctionAppDirectory)) == null)
            {
                return(new UnauthorizedResult());
            }
            /*Code*/
            List <Reservations>   reservations    = db.GetAllReservations();
            List <ReservationDto> responseMessage = _mapper.Map <List <Reservations>, List <ReservationDto> >(reservations);

            return(new OkObjectResult(responseMessage));
        }
        public async Task <IActionResult> AddReservation(
            [HttpTrigger(AuthorizationLevel.Function, "Post", Route = "ReservationFunctionApi")] HttpRequestMessage req, ExecutionContext context)
        {
            /*Validate JWT*/
            if ((SecurityJwt.ValidateToken(req.Headers.Authorization, context.FunctionAppDirectory)) == null)
            {
                return(new UnauthorizedResult());
            }
            /*Code*/
            var content = await req.Content.ReadAsStringAsync();

            ReservationDto reservationDto  = JsonSerializer.Deserialize <ReservationDto>(content);
            Reservations   reservationDb   = _mapper.Map <ReservationDto, Reservations>(reservationDto);
            var            result          = db.CreateReservation(reservationDb);
            ReservationDto responseMessage = _mapper.Map <Reservations, ReservationDto>(result);

            return(new OkObjectResult(responseMessage));
        }