public bool SaveRankMessage(string RankMessageId, string RankMessage) { DataCollectionModelDataContext db = new DataCollectionModelDataContext(); try { if (Convert.ToInt32(RankMessageId) > 0) { var RankMesgs = db.RankMesgs.Where(a => a.Id == Convert.ToInt32(RankMessageId)).FirstOrDefault(); if (RankMesgs != null) { RankMesgs.Message = RankMessage; } db.SubmitChanges(); } else { RankMesg rankMesgs = new RankMesg(); rankMesgs.Message = RankMessage; db.RankMesgs.InsertOnSubmit(rankMesgs); db.SubmitChanges(); } return(true); } catch { return(false); } }
public RankMesg GetRankMsg() { SqlConnection connection = null; try { Dictionary <string, object> sqlParameterDictionary = new Dictionary <string, object>(); IDbCommand command = new SqlCommand().GetCommandWithParameters(sqlParameterDictionary, _Get_Rank_Info_Msg); connection = DBConnectionHelper.OpenNewSqlConnection(this.ConnectionString); command.Connection = connection; SqlDataAdapter dataAdapter = new SqlDataAdapter(); DataSet RankMesgDataset = new DataSet(); dataAdapter.SelectCommand = (SqlCommand)command; dataAdapter.Fill(RankMesgDataset); List <RankMesg> rankUserMenu1 = EntityMapper.MapCollection <RankMesg>(RankMesgDataset.Tables[0]).ToList(); RankMesg rankMesg = rankUserMenu1.Count > 0 ? rankUserMenu1.FirstOrDefault() : new RankMesg(); return(rankMesg); } finally { DBConnectionHelper.CloseSqlConnection(connection); } }