示例#1
0
        public async Task <AuthorDTO> GetByIdAuthor(int id)
        {
            string baseUrl = BaseRestService.GetConnectionStringByName(false);

            using RestService <AuthorDTO> restService = new RestService <AuthorDTO>(baseUrl);
            return(await restService.POSTAsync($"{webApi}{id}", null, false));
        }
示例#2
0
        public async Task <bool> DeleteAuthor(int id)
        {
            string baseUrl = BaseRestService.GetConnectionStringByName(false);

            using RestService <bool> restService = new RestService <bool>(baseUrl);
            return(await restService.DELETEAsync(webApi));
        }
示例#3
0
        public async Task <IEnumerable <AuthorListDTO> > GetAllAuthors()
        {
            string baseUrl = BaseRestService.GetConnectionStringByName(false);

            using RestService <IEnumerable <AuthorListDTO> > restService = new RestService <IEnumerable <AuthorListDTO> >(baseUrl);
            return(await restService.GETAsync(webApi));
        }
示例#4
0
        public async Task <T> GetById(string webApi)
        {
            string baseUrl = BaseRestService.GetConnectionStringByName(false);

            using (RestService <T> restService = new RestService <T>(baseUrl))
            {
                return(await restService.POSTAsync(webApi, null, false));
            }
        }
示例#5
0
        public async Task <IEnumerable <T> > GetAll(string webApi)
        {
            string baseUrl = BaseRestService.GetConnectionStringByName(false);

            using (RestService <IEnumerable <T> > restService = new RestService <IEnumerable <T> >(baseUrl))
            {
                return(await restService.GETAsync(webApi));
            }
        }
示例#6
0
        public async Task <T> Delete(string webApi)
        {
            string baseUrl = BaseRestService.GetConnectionStringByName(false);

            using (RestService <T> restService = new RestService <T>(baseUrl))
            {
                return(await restService.DELETEAsync(webApi));
            }
        }
示例#7
0
        public async Task <bool> CreateAuthor(AuthorDTO author, bool isNewItem)
        {
            string baseUrl = BaseRestService.GetConnectionStringByName(false);

            using RestService <bool> restService = new RestService <bool>(baseUrl);
            if (isNewItem)
            {
                return(await restService.POSTAsync(webApi, author, false));
            }
            else
            {
                return(await restService.POSTAsync(webApi, author, true));
            }
        }
示例#8
0
        public async Task <T> Create(T entity, bool isNewItem, string webApi)
        {
            string baseUrl = BaseRestService.GetConnectionStringByName(false);

            using (RestService <T> restService = new RestService <T>(baseUrl))
            {
                if (isNewItem)
                {
                    return(await restService.POSTAsync(webApi, entity, false));
                }
                else
                {
                    return(await restService.POSTAsync(webApi, entity, true));
                }
            }
        }