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); }
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())); }
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); }