private async void InsertComment(DinnerDecisionComments comment) { // This code inserts a new TodoItem into the database. When the operation completes // and Mobile Services has assigned an Id, the item is added to the CollectionView try { CommentUploadStatus.Text = ""; await App.MobileService.GetTable<DinnerDecisionComments>().InsertAsync(comment); CommentUploadStatus.Text = "上传成功"; } catch (Exception) { CommentUploadStatus.Text = "上传失败"; throw; } }
private void CommentSaveButton_Click(object sender, RoutedEventArgs e) { var comment = new DinnerDecisionComments { Location = current.CurrentItemContent, Comments = CommentTextBox.Text, IsBad = false, IsGood = false }; InsertComment(comment); // ////Test // //String[] commentsLib = {"量真叫一个小呀", // // "量很大", // // "价格不错", // // "价格便宜", // // "价格好贵", // // "吃不饱", // // "胖子很喜欢吃", // // "每周都要去吃", // // "吃了一次就不想吃了", // // "肉太少了", // // "很地道!", // // "味道一般", // // "还不如大排档", // // "人不是很多", // // "感觉很舒服", // // "伙计很有礼貌", // // "服务不错", // // "服务一般", // // "随便吃吃而已", // // "小吃不错", // // "口味较多", // // "味道不错", // // "生意超级好", // // "我爱吃", // // "排队太久了", // // "名家口味", // // "大厨很赞", // // "就喜欢这口", // // "平均每人50元", // // "平均每人60元", // // "服务不太好", // // "餐厅有点脏", // // "价格便宜味道贴心", // // "果汁和小食很爽口", // // "逛街时吃饭的好选择", // // "慕名而去,没有失望", // // "非常的美味", // // "今晚吃神马是个好应用", // // "今晚吃神马是个好应用", // // "今晚吃神马是个好应用", // // "今晚吃神马是个好应用", // // "今晚吃神马是个好应用", // // "今晚吃神马是个好应用", // // "今晚吃神马是个好应用", // // "今晚吃神马是个好应用", // // "今晚吃神马是个好应用", // // "餐后还有西瓜送,太难吃,还是不送的好", // // "菜有些少", // // "口感中上级别", // // "东西很多,每道菜都很精致" // // }; // //Random r = new Random(); // //foreach (var item in Menu.menu) // //{ // // for (int i = 0; i < 10; i++) // // { // // var comment = new DinnerDecisionComments { Location = item, Comments = commentsLib[r.Next(commentsLib.Length)], IsBad = false, IsGood = false }; // // InsertComment(comment); // // } // //} }