Exemplo n.º 1
0
        protected virtual HttpRequestMessage CreateRequest <T>(PostEntityCommand <T> cmd) where T : class
        {
            var req = new HttpRequest(HttpMethod.Post, GenerateRequestUrl());

            req.SetContent(SerializeEntity(cmd.Entity));

            return(req);
        }
Exemplo n.º 2
0
        public virtual async Task <EntityResponse <T> > PostAsync <T>(PostEntityCommand <T> cmd) where T : class
        {
            Ensure.That(cmd, "cmd").IsNotNull();

            var req = CreateRequest(cmd);
            var res = SendAsync(req);

            return(ProcessEntityResponse(cmd, await res.ForAwait()));
        }
Exemplo n.º 3
0
        protected virtual EntityResponse <T> ProcessEntityResponse <T>(PostEntityCommand <T> cmd, HttpResponseMessage response) where T : class
        {
            var entityResponse = EntityResponseFactory.Create <T>(response);

            entityResponse.Entity = cmd.Entity;

            if (entityResponse.IsSuccess)
            {
                Reflector.IdMember.SetValueTo(entityResponse.Entity, entityResponse.Id);
                Reflector.RevMember.SetValueTo(entityResponse.Entity, entityResponse.Rev);
            }

            return(entityResponse);
        }