private async void Button_Clicked(object sender, EventArgs e) { GoodsDetailViewModel gdvm = BindingContext as GoodsDetailViewModel; if (gdvm.GoodsModel.User.Name == App.StaticUser.Name) { await App.GoodsManager.DeleteGoodsTaskAsync(gdvm.GoodsModel); GoodsViewModel.refresh(); DependencyService.Get <IToastService>().LongAlert("删除商品成功!"); await Navigation.PopAsync(); } else { if (App.StaticUser.TomatoPoints >= gdvm.GoodsModel.Price) { App.StaticUser.TomatoPoints -= gdvm.GoodsModel.Price; await App.UserManager.ModifyUserTaskAsync(App.StaticUser); DependencyService.Get <IToastService>().LongAlert("购买商品成功!"); await Navigation.PopAsync(); } else { DependencyService.Get <IToastService>().LongAlert("番茄点不足,不能购买!"); } } }
private async void Button_Clicked(object sender, EventArgs e) { AddGoodsViewModel agvm = BindingContext as AddGoodsViewModel; agvm.GoodsModel.Type = comboBox.SelectedItem.ToString(); agvm.GoodsModel.Date = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); agvm.GoodsModel.Uri = gm.Uri; agvm.GoodsModel.UserId = App.StaticUser.UserId; Random ran = new Random(); long RandKey = ran.Next(0, 9999); agvm.GoodsModel.Id = RandKey; await App.GoodsManager.AddGoodsTaskAsync(agvm.GoodsModel); GoodsViewModel.refresh(); DependencyService.Get <IToastService>().LongAlert("增加商品成功!"); await Navigation.PopAsync(); }
private void ListView_Refreshing(object sender, EventArgs e) { GoodsViewModel.refresh(); listview.EndRefresh(); }