public bool CreateDailyNews(CoreMVCBackend.Model.DailyNews.DailyNews DailyNews, string Conn) { if (DailyNews.NewsDate == null || string.IsNullOrWhiteSpace(DailyNews.Subject) || string.IsNullOrWhiteSpace(DailyNews.Context)) { throw new Exception("參數遺失"); } else { return(_dailyNewsData.CreateDailyNews(DailyNews, Conn)); } }
public bool CreateDailyNews(CoreMVCBackend.Model.DailyNews.DailyNews DailyNews, string Conn) { using (MySqlConnection sqlConnection = new MySqlConnection(Conn)){ bool result = false; SQLs.Clear(); SQLs.AppendLine("INSERT into CoreMVCBackend.DailyNews "); SQLs.AppendLine("(NewsDate,Subject,Context,Status) "); SQLs.AppendLine("VALUES "); SQLs.AppendLine("(@NewsDate,@Subject,@Context,@Status) "); object param = new{ NewsDate = DailyNews.NewsDate, Subject = DailyNews.Subject, Context = DailyNews.Context, Status = DailyNews.Status }; result = sqlConnection.Execute(SQLs.ToString(), param) == 0?false:true; return(result); } }