Example #1
0
        public async Task <EResponseBase <BillDetailProxy> > DeleteCustomerAsync(int ID)
        {
            var    client  = new HttpClient();
            string baseUrl = ApiUrlHelper.BaseUrl();

            client.BaseAddress = new Uri(baseUrl);

            var url      = string.Concat(baseUrl, "/api/", "BillDetail/", "DeleteBillDetail/", ID);
            var response = client.DeleteAsync(url).Result;

            if (response.StatusCode == HttpStatusCode.OK)
            {
                var result = await response.Content.ReadAsStringAsync();

                var exito = JsonConvert.DeserializeObject <bool>(result);
                return(new EResponseBase <BillDetailProxy>
                {
                    Status = exito,
                    Code = 0,
                    Message = "Exito"
                });
            }
            else
            {
                return(new EResponseBase <BillDetailProxy>
                {
                    Status = false,
                    Code = (int)response.StatusCode,
                    Message = "Error"
                });
            }
        }
Example #2
0
        public async Task <EResponseBase <BillDetailProxy> > DetailCustomerAsync(int ID)
        {
            var    client  = new HttpClient();
            string baseUrl = ApiUrlHelper.BaseUrl();

            client.BaseAddress = new Uri(baseUrl);

            var url      = string.Concat(baseUrl, "/api/", "BillDetail/", "GetBillDetail/", ID);
            var response = client.GetAsync(url).Result;

            if (response.StatusCode == HttpStatusCode.OK)
            {
                var result = await response.Content.ReadAsStringAsync();

                var BillDetail = JsonConvert.DeserializeObject <BillDetailProxy>(result);
                return(new EResponseBase <BillDetailProxy>
                {
                    Status = true,
                    Code = (int)HttpStatusCode.OK,
                    Message = "Status",
                    Object = BillDetail
                });
            }
            else
            {
                return(new EResponseBase <BillDetailProxy>
                {
                    Code = (int)response.StatusCode,
                    Message = "Error"
                });
            }
        }
        public async Task <ResponseProxy <CustomerModel> > SearchCustomersAsync(string query)
        {
            var    client  = new HttpClient();
            string baseUrl = ApiUrlHelper.BaseUrl();

            client.BaseAddress = new Uri(baseUrl);

            var url      = string.Concat(baseUrl, "/api/", "Customer/", "SearchCustomers?query=", query);
            var response = client.GetAsync(url).Result;

            if (response.StatusCode == HttpStatusCode.OK)
            {
                var result = await response.Content.ReadAsStringAsync();

                var Customers = JsonConvert.DeserializeObject <List <CustomerModel> >(result);
                return(new ResponseProxy <CustomerModel>
                {
                    Status = true,
                    Code = (int)HttpStatusCode.OK,
                    Message = "Status",
                    List = Customers
                });
            }
            else
            {
                return(new ResponseProxy <CustomerModel>
                {
                    Code = (int)response.StatusCode,
                    Message = "Error"
                });
            }
        }
Example #4
0
        public async Task <EResponseBase <DataBillModel> > InsertAsync(DataBillModel order)
        {
            try
            {
                var    request = JsonConvert.SerializeObject(order);
                var    content = new StringContent(request, Encoding.UTF8, "application/json");
                var    client  = new HttpClient();
                string baseUrl = ApiUrlHelper.BaseUrl();
                client.BaseAddress = new Uri(baseUrl);
                var url = string.Concat(baseUrl, "/api/BillDetail/InsertBillDetail");

                var response = client.PostAsync(url, content).Result;

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    var result = await response.Content.ReadAsStringAsync();

                    var exito = JsonConvert.DeserializeObject <bool>(result);
                    return(new EResponseBase <DataBillModel>
                    {
                        Status = exito,
                        Code = 0,
                        Message = "Exito"
                    });
                }
                else
                {
                    return(new EResponseBase <DataBillModel>
                    {
                        Status = false,
                        Code = (int)response.StatusCode,
                        Message = "Error"
                    });
                }
            }
            catch (Exception ex)
            {
                return(new EResponseBase <DataBillModel>
                {
                    Code = 404,
                    Message = ex.Message
                });

                throw;
            }
        }
        public async Task <ResponseProxy <CustomerModel> > InsertAsync(CustomerModel Customer)
        {
            var request = JsonConvert.SerializeObject(Customer);
            var content = new StringContent(request, Encoding.UTF8, "application/json");



            var    client  = new HttpClient();
            string baseUrl = ApiUrlHelper.BaseUrl();

            client.BaseAddress = new Uri(baseUrl);
            var url = string.Concat(baseUrl, "/api/Customer/InsertCustomer");

            var response = client.PostAsync(url, content).Result;

            if (response.StatusCode == HttpStatusCode.OK)
            {
                var result = await response.Content.ReadAsStringAsync();

                var exito = JsonConvert.DeserializeObject <bool>(result);
                return(new ResponseProxy <CustomerModel>
                {
                    Status = exito,
                    Code = 0,
                    Message = "Exito"
                });
            }
            else
            {
                return(new ResponseProxy <CustomerModel>
                {
                    Status = false,
                    Code = (int)response.StatusCode,
                    Message = "Error"
                });
            }
        }
Example #6
0
        public async Task <EResponseBase <BillDetailProxy> > GetBillsAsync()
        {
            try
            {
                var    client  = new HttpClient();
                string baseUrl = ApiUrlHelper.BaseUrl();
                client.BaseAddress = new Uri(baseUrl);

                var url      = string.Concat(baseUrl, "/api/", "BillDetail/", "GetAllBillDetails");
                var response = client.GetAsync(url).Result;
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    var result = await response.Content.ReadAsStringAsync();

                    return(JsonConvert.DeserializeObject <EResponseBase <BillDetailProxy> >(result));
                }
                else
                {
                    return(new EResponseBase <BillDetailProxy>
                    {
                        Code = (int)response.StatusCode,
                        Message = "Error"
                    });
                }
            }
            catch (Exception ex)
            {
                return(new EResponseBase <BillDetailProxy>
                {
                    Code = 404,
                    Message = ex.Message
                });

                throw;
            }
        }
Example #7
0
        public async Task <EResponseBase <BillDetailProxy> > UpdateAsync(BillDetailProxy BillDetail)
        {
            var request = JsonConvert.SerializeObject(BillDetail);
            var content = new StringContent(request, Encoding.UTF8, "application/json");

            var    client  = new HttpClient();
            string baseUrl = ApiUrlHelper.BaseUrl();

            client.BaseAddress = new Uri(baseUrl);

            var url = string.Concat(baseUrl, "/api/BillDetail/UpdateBillDetail");

            var response = client.PutAsync(url, content).Result;

            if (response.StatusCode == HttpStatusCode.OK)
            {
                var result = await response.Content.ReadAsStringAsync();

                var exito = JsonConvert.DeserializeObject <bool>(result);
                return(new EResponseBase <BillDetailProxy>
                {
                    Status = exito,
                    Code = 0,
                    Message = "Exito"
                });
            }
            else
            {
                return(new EResponseBase <BillDetailProxy>
                {
                    Status = false,
                    Code = (int)response.StatusCode,
                    Message = "Error"
                });
            }
        }