コード例 #1
0
 public void Init(OnlineProduct item)
 {
     if (item.Barcode == null)
     {
         item.Barcode = "";
     }
     if (item.IsBestSale == null)
     {
         item.IsBestSale = false;
     }
     if (item.IsNew == null)
     {
         item.IsNew = false;
     }
     if (item.UnitCode == null)
     {
         item.UnitCode = "";
     }
     if (item.Remain == null)
     {
         item.Remain = 0;
     }
     if (item.Price == null)
     {
         item.Price = 0;
     }
     if (item.WholeSalePrice == null)
     {
         item.WholeSalePrice = 0;
     }
     if (item.UpdatedDate == null)
     {
         item.UpdatedDate = DateTime.Now;
     }
 }
コード例 #2
0
        public async Task SaveProductAsync(OnlineProduct item, bool isNewItem = false)
        {
            try {
                var json    = JsonConvert.SerializeObject(item);
                var content = new StringContent(json, Encoding.UTF8, "application/json");

                HttpResponseMessage response = null;
                if (isNewItem)
                {
                    response = await client.PostAsync(new Uri(string.Format(Constants.ProductInsert, String.Empty)), content);

                    //await db.SaveProductAsync(JsonConvert.DeserializeObject<StoreMobile.OnlineProduct>(content));
                }
                else
                {
                    response = await client.PutAsync(new Uri(string.Format(Constants.ProductUpdate, String.Empty)), content);
                }

                if (response.IsSuccessStatusCode)
                {
                    Debug.WriteLine(@"Item successfully saved.");
                }
            } catch (Exception ex) {
                Debug.WriteLine(@"ERROR {0}", ex.Message);
            }
        }
コード例 #3
0
        void OnAddItemClicked(object sender, EventArgs e)
        {
            var OnlineProduct = new OnlineProduct();
            //var OnlineProduct = new OnlineProduct () {
            //	Id = Guid.NewGuid ().ToString ()
            //};
            var todoPage = new ProductPage(true);

            todoPage.BindingContext = OnlineProduct;
            Navigation.PushAsync(todoPage);
        }
コード例 #4
0
 public Task DeleteProductTaskAsync(OnlineProduct item)
 {
     return(restService.DeleteProductAsync(Convert.ToInt32(item.Id)));
 }
コード例 #5
0
 public Task SaveProductTaskAsync(OnlineProduct item, bool isNewItem = false)
 {
     return(restService.SaveProductAsync(item, isNewItem));
 }