public virtual TModel Get(int id)
        {
            string url = ApiServerUrl + ControllerRoute + id;
            MyHttpRequestMessage request = new MyHttpRequestMessage(url, HttpMethod.Get);
            var task = request.Execute <TModel>();

            task.Wait();
            return(task.Result);
        }
        public virtual TModel Update(TModel obj, int id)
        {
            string url = ApiServerUrl + ControllerRoute + id;
            MyHttpRequestMessage request = new MyHttpRequestMessage(url, HttpMethod.Put)
            {
                RequestBody = new StringContent(JsonConvert.SerializeObject(obj), System.Text.Encoding.UTF8, "application/json")
            };
            var task = request.Execute <TModel>();

            task.Wait();
            return(task.Result);
        }
        public virtual List <TModel> Get(GenericDataFormat requestBody)
        {
            string url = ApiServerUrl + ControllerRoute + "get";
            MyHttpRequestMessage request = new MyHttpRequestMessage(url, HttpMethod.Post)
            {
                RequestBody = new StringContent(JsonConvert.SerializeObject(requestBody), System.Text.Encoding.UTF8, "application/json")
            };
            var task = request.Execute <List <TModel> >();

            task.Wait();
            return(task.Result);
        }
        public virtual bool Delete(int id)
        {
            string url = ApiServerUrl + ControllerRoute + id;
            MyHttpRequestMessage request = new MyHttpRequestMessage(url, HttpMethod.Delete);
            var task = request.Execute <String>();

            task.Wait();
            if (task.Result.ToString().Equals("Success", StringComparison.OrdinalIgnoreCase))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #5
0
        public virtual bool Deactive(object[] ids)
        {
            string url = ApiServerUrl + ControllerRoute + "deactive";
            MyHttpRequestMessage request = new MyHttpRequestMessage(url, HttpMethod.Post)
            {
                RequestBody = new StringContent(JsonConvert.SerializeObject(ids), System.Text.Encoding.UTF8, "application/json")
            };
            var task = request.Execute <String>();

            task.Wait();
            if (task.Result.ToString().Equals("Success", StringComparison.OrdinalIgnoreCase))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #6
0
        public virtual bool Import(TModel[] objs)
        {
            string url = ApiServerUrl + ControllerRoute + "import";
            MyHttpRequestMessage request = new MyHttpRequestMessage(url, HttpMethod.Post)
            {
                RequestBody = new StringContent(JsonConvert.SerializeObject(objs), System.Text.Encoding.UTF8, "application/json")
            };
            var task = request.Execute <string>();

            task.Wait();

            if (task.Result != null && task.Result.ToString().Contains("Success"))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }