Ejemplo n.º 1
0
        public T Add(T entity)
        {
            RestSharpCall.Init(apiContext.CurrentContext.Uri + urlValues, RestSharpMethod.POST);
            var apiResponse = RestSharpCall.MakeAsync <object>(parameters, headers, null, null, null, entity);

            return(entity);
        }
Ejemplo n.º 2
0
        public dynamic Update(T entity)
        {
            RestSharpCall.Init(apiContext.CurrentContext.Uri + urlValues, RestSharpMethod.PUT);
            var response = RestSharpCall.MakeAsync <object>(parameters, headers, null, null, null, entity);

            return(response);
        }
Ejemplo n.º 3
0
        public dynamic Delete(dynamic id)
        {
            RestSharpCall.Init(apiContext.CurrentContext.Uri + "/" + id, RestSharpMethod.DELETE);
            var response = RestSharpCall.MakeAsync <object>(null, headers);

            return(response);
        }
Ejemplo n.º 4
0
        public T Get()
        {
            RestSharpCall.Init(apiContext.CurrentContext.Uri + urlValues, RestSharpMethod.GET);
            var apiResponse = RestSharpCall.MakeAsync <object>(parameters, headers, null, null, null, null);

            if (apiResponse != null)
            {
                T response = JsonConvert.DeserializeObject <T>(apiResponse.ToString());
                return(response);
            }
            return(null);
        }
Ejemplo n.º 5
0
        public IQueryable <T> GetAll()
        {
            IList <T> response = new List <T>();

            RestSharpCall.Init(apiContext.CurrentContext.Uri + urlValues, RestSharpMethod.GET);
            var apiResponse = RestSharpCall.MakeAsync <List <object> >(parameters, headers);

            if (apiResponse != null)
            {
                apiResponse.ForEach(x =>
                {
                    response.Add(JsonConvert.DeserializeObject <T>(x.ToString()));
                });
            }

            return(response.AsQueryable());
        }