Example #1
0
        public async Task <CommandResult> DeleteContact(int id, CancellationToken cancellationToken = new CancellationToken())
        {
            var url = ApiRouteBase.AppendPathSegment(id);

            return(await url.DeleteAsync(cancellationToken)
                   .ReceiveJson <CommandResult>());
        }
Example #2
0
 public async Task <CommandResult> UpdateContact(int id, ContactModel contactModel, CancellationToken cancellationToken = new CancellationToken())
 {
     return(await ApiRouteBase
            .AppendPathSegment(id)
            .PutJsonAsync(contactModel, cancellationToken)
            .ReceiveJson <CommandResult>());
 }
Example #3
0
        public async Task <PagedResult <ContactSummary> > GetSummary(int page, int pageSize, CancellationToken cancellationToken = new CancellationToken())
        {
            var url = ApiRouteBase
                      .AppendPathSegment(nameof(GetSummary))
                      .SetQueryParam(nameof(page), page)
                      .SetQueryParam(nameof(pageSize), pageSize);

            return(await url.GetJsonAsync <PagedResult <ContactSummary> >(cancellationToken));
        }
Example #4
0
        public async Task <long> Count(CancellationToken cancellationToken = new CancellationToken())
        {
            var url      = ApiRouteBase.AppendPathSegment(nameof(Count));
            var response = await url.GetStringAsync(cancellationToken);

            if (long.TryParse(response, out var count))
            {
                return(count);
            }
            return(-1);
        }
        public async Task <T> GetById(int id, string select = null, string expand = null,
                                      CancellationToken cancellationToken = new CancellationToken())
        {
            var url = ApiRouteBase.AppendPathSegment(id);

            url = BuildODataUrl(url, select, expand);
            var result = await url
                         .SetQueryParam("$filter", $"id eq {id}")
                         .GetJsonAsync <PageResult <T> >(cancellationToken);

            return(result.Items.FirstOrDefault());
        }
Example #6
0
        public async Task <ContactModel> GetById(int id, CancellationToken cancellationToken = new CancellationToken())
        {
            var url = ApiRouteBase.AppendPathSegment(id);

            return(await url.GetJsonAsync <ContactModel>(cancellationToken));
        }
Example #7
0
        public async Task <IEnumerable <ContactModel> > GetAll(CancellationToken cancellationToken = new CancellationToken())
        {
            var url = ApiRouteBase.AppendPathSegment(nameof(GetAll));

            return(await url.GetJsonAsync <IEnumerable <ContactModel> >(cancellationToken));
        }
Example #8
0
 public ContactClient(string apiRouteBase) : base(apiRouteBase)
 {
     ApiRouteBase = ApiRouteBase.AppendPathSegment("Contact");
 }
Example #9
0
 public FakeNameClient(string apiRouteBase) : base(apiRouteBase)
 {
     ApiRouteBase = ApiRouteBase.AppendPathSegment("FakeName");
 }