示例#1
0
        public async Task <ObservableCollection <ProductModel> > GetProduct()
        {
            ObservableCollection <ProductModel> productList = null;


            UserDialogs.Instance.ShowLoading();
            Rest_Response rest_result = await WebService.GetData("Product/GetProductList");

            if (rest_result != null)
            {
                if (rest_result.status_code == 200)
                {
                    RootObjectProduct data = JsonConvert.DeserializeObject <RootObjectProduct>(rest_result.response_body);
                    if (data.StatusCode == 200)
                    {
                        productList = data.Result;
                    }
                }
            }
            UserDialogs.Instance.HideLoading();
            return(productList);
        }
示例#2
0
        private async void ExecuteAddItemCommand()
        {
            if (CheckValidations())
            {
                ProductModel product = new ProductModel();
                product.Name  = Name;
                product.Price = Convert.ToDouble(Price);

                product.Qty   = Convert.ToInt16(Qty);
                product.Image = ItemImage;
                product.Desc  = Desc;
                product.Type  = Type;

                UserDialogs.Instance.ShowLoading();

                Rest_Response rest_result = await WebService.PostData(product, "Product/AddProduct");

                if (rest_result != null)
                {
                    if (rest_result.status_code == 200)
                    {
                        RootObjectProduct data = JsonConvert.DeserializeObject <RootObjectProduct>(rest_result.response_body);
                        if (data.StatusCode == 200)
                        {
                            var userobj = data.Result;
                            UserDialogs.Instance.Alert("Item Added", null, "OK");
                        }
                    }
                    else
                    {
                        UserDialogs.Instance.Alert("Product Already Added");
                    }
                }
                UserDialogs.Instance.HideLoading();
            }
        }