Пример #1
0
        public virtual async Task <OfmQueryResult <TOfmForGet> > Patch(TId id, JsonPatchDocument jsonPatchDocument)
        {
            var ofmQueryResult = new OfmQueryResult <TOfmForGet>();
            var uri            = new Uri(
                AppConfiguration.GetValue <string>("FittifyApiBaseUrl")
                + AppConfiguration.GetValue <string>("MappedFittifyApiActions:" + MappedControllerActionKey)
                + "/" + id
                );
            var httpResponse = await HttpRequestExecuter.Patch(uri, jsonPatchDocument, AppConfiguration, HttpContextAccessor);

            ofmQueryResult.HttpStatusCode      = httpResponse.StatusCode;
            ofmQueryResult.HttpResponseHeaders = httpResponse.Headers.ToList();

            if (!Regex.Match(((int)ofmQueryResult.HttpStatusCode).ToString(), FittifyRegularExpressions.HttpStatusCodeStartsWith2).Success)
            {
                ofmQueryResult.ErrorMessagesPresented = httpResponse.ContentAsType <IReadOnlyDictionary <string, object> >();
            }
            else
            {
                ofmQueryResult.OfmForGet = httpResponse.ContentAsType <TOfmForGet>();
            }
            return(ofmQueryResult);
        }