Esempio n. 1
0
        /// <summary>
        /// 删除反馈内容
        /// </summary>
        /// <param name="Item">反馈对象</param>
        /// <returns></returns>
        public async Task <bool> DeleteFeedBackAsync(FeedBackItem Item)
        {
            if (Item != null)
            {
                if (await MakeConnectionUseable().ConfigureAwait(false))
                {
                    try
                    {
                        using (MySqlCommand Command = new MySqlCommand("Delete From FeedBackTable Where GUID=@GUID", Connection))
                        {
                            Command.Parameters.AddWithValue("@GUID", Item.GUID);
                            await Command.ExecuteNonQueryAsync().ConfigureAwait(false);
                        }

                        return(true);
                    }
                    catch (Exception ex)
                    {
                        LogTracer.Log(ex, $"An error was threw in { nameof(DeleteFeedBackAsync)}");
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                throw new ArgumentNullException(nameof(Item), "Parameter could not be null");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 删除反馈内容
        /// </summary>
        /// <param name="Item">反馈对象</param>
        /// <returns></returns>
        public async Task <bool> DeleteFeedBackAsync(FeedBackItem Item)
        {
            if (Item != null)
            {
                using (SQLConnection Connection = await GetConnectionFromPoolAsync().ConfigureAwait(false))
                {
                    if (Connection.IsConnected)
                    {
                        try
                        {
                            using (MySqlCommand Command = Connection.CreateDbCommandFromConnection <MySqlCommand>("Delete From FeedBackTable Where GUID=@GUID"))
                            {
                                _ = Command.Parameters.AddWithValue("@GUID", Item.GUID);
                                _ = Command.ExecuteNonQuery();
                            }

                            return(true);
                        }
                        catch (Exception)
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            else
            {
                throw new ArgumentNullException(nameof(Item), "Parameter could not be null");
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 提交反馈内容
 /// </summary>
 /// <param name="Item">反馈对象</param>
 /// <returns></returns>
 public async Task <bool> SetFeedBackAsync(FeedBackItem Item)
 {
     if (Item != null)
     {
         using (SQLConnection Connection = await GetConnectionFromPoolAsync().ConfigureAwait(false))
         {
             if (Connection.IsConnected)
             {
                 try
                 {
                     using (MySqlCommand Command = Connection.CreateDbCommandFromConnection <MySqlCommand>("Insert Into FeedBackTable Values (@UserName,@Title,@Suggestion,@Like,@Dislike,@UserID,@GUID)"))
                     {
                         _ = Command.Parameters.AddWithValue("@UserName", Item.UserName);
                         _ = Command.Parameters.AddWithValue("@Title", Item.Title);
                         _ = Command.Parameters.AddWithValue("@Suggestion", Item.Suggestion);
                         _ = Command.Parameters.AddWithValue("@Like", Item.LikeNum);
                         _ = Command.Parameters.AddWithValue("@Dislike", Item.DislikeNum);
                         _ = Command.Parameters.AddWithValue("@UserID", Item.UserID);
                         _ = Command.Parameters.AddWithValue("@GUID", Item.GUID);
                         _ = Command.ExecuteNonQuery();
                     }
                     return(true);
                 }
                 catch (Exception)
                 {
                     return(false);
                 }
             }
             else
             {
                 return(false);
             }
         }
     }
     else
     {
         throw new ArgumentNullException(nameof(Item), "Parameter could not be null");
     }
 }
Esempio n. 4
0
        /// <summary>
        /// 提交反馈内容
        /// </summary>
        /// <param name="Item">反馈对象</param>
        /// <returns></returns>
        public async Task <bool> SetFeedBackAsync(FeedBackItem Item)
        {
            if (Item != null)
            {
                if (await MakeConnectionUseable().ConfigureAwait(false))
                {
                    try
                    {
                        using (MySqlCommand Command = new MySqlCommand("Insert Into FeedBackTable Values (@UserName,@Title,@Suggestion,@Like,@Dislike,@UserID,@GUID)", Connection))
                        {
                            Command.Parameters.AddWithValue("@UserName", Item.UserName);
                            Command.Parameters.AddWithValue("@Title", Item.Title);
                            Command.Parameters.AddWithValue("@Suggestion", Item.Suggestion);
                            Command.Parameters.AddWithValue("@Like", Item.LikeNum);
                            Command.Parameters.AddWithValue("@Dislike", Item.DislikeNum);
                            Command.Parameters.AddWithValue("@UserID", Item.UserID);
                            Command.Parameters.AddWithValue("@GUID", Item.GUID);
                            await Command.ExecuteNonQueryAsync().ConfigureAwait(false);
                        }

                        return(true);
                    }
                    catch (Exception ex)
                    {
                        LogTracer.Log(ex, $"An error was threw in { nameof(SetFeedBackAsync)}");
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                throw new ArgumentNullException(nameof(Item), "Parameter could not be null");
            }
        }
Esempio n. 5
0
 /// <summary>
 /// 更新反馈对象的投票信息
 /// </summary>
 /// <param name="Item">反馈对象</param>
 /// <returns></returns>
 public async Task <bool> UpdateFeedBackVoteAsync(FeedBackItem Item)
 {
     if (Item != null)
     {
         using (SQLConnection Connection = await GetConnectionFromPoolAsync().ConfigureAwait(false))
         {
             if (Connection.IsConnected)
             {
                 try
                 {
                     using (MySqlCommand Command = Connection.CreateDbCommandFromConnection <MySqlCommand>("UpdateFeedBackVoteProcedure", CommandType.StoredProcedure))
                     {
                         _ = Command.Parameters.AddWithValue("LNum", Item.LikeNum);
                         _ = Command.Parameters.AddWithValue("DNum", Item.DislikeNum);
                         _ = Command.Parameters.AddWithValue("Beh", Item.UserVoteAction);
                         _ = Command.Parameters.AddWithValue("GID", Item.GUID);
                         _ = Command.Parameters.AddWithValue("UID", ApplicationData.Current.LocalSettings.Values["SystemUserID"].ToString());
                         _ = await Command.ExecuteNonQueryAsync().ConfigureAwait(false);
                     }
                     return(true);
                 }
                 catch (Exception)
                 {
                     return(false);
                 }
             }
             else
             {
                 return(false);
             }
         }
     }
     else
     {
         throw new ArgumentNullException(nameof(Item), "Parameter could not be null");
     }
 }
Esempio n. 6
0
 /// <summary>
 /// 更新反馈对象的投票信息
 /// </summary>
 /// <param name="Item">反馈对象</param>
 /// <returns></returns>
 public async Task <bool> UpdateFeedBackVoteAsync(FeedBackItem Item)
 {
     if (Item != null)
     {
         if (await MakeConnectionUseable().ConfigureAwait(false))
         {
             try
             {
                 using (MySqlCommand Command = new MySqlCommand("UpdateFeedBackVoteProcedure", Connection))
                 {
                     Command.CommandType = CommandType.StoredProcedure;
                     Command.Parameters.AddWithValue("LNum", Item.LikeNum);
                     Command.Parameters.AddWithValue("DNum", Item.DislikeNum);
                     Command.Parameters.AddWithValue("Beh", Item.UserVoteAction);
                     Command.Parameters.AddWithValue("GID", Item.GUID);
                     Command.Parameters.AddWithValue("UID", ApplicationData.Current.LocalSettings.Values["SystemUserID"].ToString());
                     await Command.ExecuteNonQueryAsync().ConfigureAwait(false);
                 }
                 return(true);
             }
             catch (Exception ex)
             {
                 LogTracer.Log(ex, $"An error was threw in {nameof(UpdateFeedBackVoteAsync)}");
                 return(false);
             }
         }
         else
         {
             return(false);
         }
     }
     else
     {
         throw new ArgumentNullException(nameof(Item), "Parameter could not be null");
     }
 }