Exemplo n.º 1
0
        public override bool CanHandleChangeRequest(ChangeRequest changeRequest, out ChangeItemRequest changeItemRequest)
        {
            changeItemRequest = null;
            if (changeRequest.Requests.Length == 1 && ShiftPreferenceRequestUriTemplate.TryMatch(changeRequest.Requests[0].Url, out _))
            {
                changeItemRequest = changeRequest.Requests[0];
            }

            return(changeItemRequest != null);
        }
        protected static bool CanHandleChangeRequest(ChangeRequest changeRequest, UriTemplate uriTemplate, out ChangeItemRequest changeItemRequest)
        {
            changeItemRequest = null;
            foreach (var request in changeRequest.Requests)
            {
                if (uriTemplate.TryMatch(request.Url, out var changeItemParams))
                {
                    changeItemRequest = request;
                    break;
                }
            }

            return(changeItemRequest != null);
        }
        public override bool CanHandleChangeRequest(ChangeRequest changeRequest, out ChangeItemRequest changeItemRequest)
        {
            // we cannot use the base class method here as we need to handle the invalid url's that
            // Teams is sending with this request
            changeItemRequest = null;
            if (changeRequest.Requests.Length == 1)
            {
                // the url as supplied by Teams looks something like the following:
                //"/shifts/SHFT_bff7961c-1bff-4c39-b2b1-7808eca233de/requestableShifts?requestType=SwapRequest&startTime=5/31/2020 11:00:00 PM +00:00&endTime=6/30/2020 10:59:59 PM +00:00"
                // because the datetime values are not valid in a url we are having to strip them so that the url parser
                // does not fail in the TryMatch method
                var request = changeRequest.Requests[0];
                var url     = request.Url.Substring(0, request.Url.IndexOf("&"));
                if (ShiftSwapFilterRequestUriTemplate.TryMatch(url, out var changeItemParams))
                {
                    if (changeItemParams.ContainsKey("requestType") && changeItemParams["requestType"].ToString().Equals("SwapRequest", StringComparison.OrdinalIgnoreCase))
                    {
                        changeItemRequest = request;
                    }
                }
            }

            return(changeItemRequest != null);
        }