public object UpdateHcBlogInfo(object param) { Database db = DatabaseFactory.CreateDatabase(); object retObj = null; using (DbConnection connection = db.CreateConnection()) { connection.Open(); DbTransaction transaction = connection.BeginTransaction(); try { HcBlogEntity hcBlogEntity = (HcBlogEntity)param; HcBlogDAL hcBlogDAL = new HcBlogDAL(); retObj = (object)hcBlogDAL.UpdateHcBlogInfo(hcBlogEntity, db, transaction); transaction.Commit(); } catch { transaction.Rollback(); throw; } finally { connection.Close(); } } return(retObj); }
public HcBlogEntity GetSingleHcBlogRecordById(object param) { Database db = DatabaseFactory.CreateDatabase(); string sql = "SELECT Id, BlogTitle, BlogDetail, isActive, BlogImage, BlogLink, CreatedBy, CreatedDate, UpdateBy, UpdateDate FROM HC_Blog WHERE Id=@Id"; DbCommand dbCommand = db.GetSqlStringCommand(sql); db.AddInParameter(dbCommand, "Id", DbType.String, param); HcBlogEntity hcBlogEntity = null; using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { hcBlogEntity = new HcBlogEntity(); if (dataReader["Id"] != DBNull.Value) { hcBlogEntity.Id = dataReader["Id"].ToString(); } if (dataReader["BlogTitle"] != DBNull.Value) { hcBlogEntity.Blogtitle = dataReader["BlogTitle"].ToString(); } if (dataReader["BlogDetail"] != DBNull.Value) { hcBlogEntity.Blogdetail = dataReader["BlogDetail"].ToString(); } if (dataReader["isActive"] != DBNull.Value) { hcBlogEntity.Isactive = dataReader["isActive"].ToString(); } if (dataReader["BlogImage"] != DBNull.Value) { hcBlogEntity.Blogimage = dataReader["BlogImage"].ToString(); } if (dataReader["BlogLink"] != DBNull.Value) { hcBlogEntity.Bloglink = dataReader["BlogLink"].ToString(); } if (dataReader["CreatedBy"] != DBNull.Value) { hcBlogEntity.Createdby = dataReader["CreatedBy"].ToString(); } if (dataReader["CreatedDate"] != DBNull.Value) { hcBlogEntity.Createddate = dataReader["CreatedDate"].ToString(); } if (dataReader["UpdateBy"] != DBNull.Value) { hcBlogEntity.Updateby = dataReader["UpdateBy"].ToString(); } if (dataReader["UpdateDate"] != DBNull.Value) { hcBlogEntity.Updatedate = dataReader["UpdateDate"].ToString(); } } } return(hcBlogEntity); }
public bool UpdateHcBlogInfo(HcBlogEntity hcBlogEntity, Database db, DbTransaction transaction) { string sql = "UPDATE HC_Blog SET BlogTitle= @Blogtitle, BlogDetail= @Blogdetail, isActive= @Isactive, BlogImage= @Blogimage, BlogLink= @Bloglink, CreatedBy= @Createdby, CreatedDate= @Createddate, UpdateBy= @Updateby, UpdateDate= @Updatedate WHERE Id=@Id"; DbCommand dbCommand = db.GetSqlStringCommand(sql); db.AddInParameter(dbCommand, "Id", DbType.String, hcBlogEntity.Id); db.AddInParameter(dbCommand, "Blogtitle", DbType.String, hcBlogEntity.Blogtitle); db.AddInParameter(dbCommand, "Blogdetail", DbType.String, hcBlogEntity.Blogdetail); db.AddInParameter(dbCommand, "Isactive", DbType.String, hcBlogEntity.Isactive); db.AddInParameter(dbCommand, "Blogimage", DbType.String, hcBlogEntity.Blogimage); db.AddInParameter(dbCommand, "Bloglink", DbType.String, hcBlogEntity.Bloglink); db.AddInParameter(dbCommand, "Createdby", DbType.String, hcBlogEntity.Createdby); db.AddInParameter(dbCommand, "Createddate", DbType.String, hcBlogEntity.Createddate); db.AddInParameter(dbCommand, "Updateby", DbType.String, hcBlogEntity.Updateby); db.AddInParameter(dbCommand, "Updatedate", DbType.String, hcBlogEntity.Updatedate); db.ExecuteNonQuery(dbCommand, transaction); return(true); }
public bool SaveHcBlogInfo(HcBlogEntity hcBlogEntity, Database db, DbTransaction transaction) { string sql = "INSERT INTO HC_Blog ( Id, BlogTitle, BlogDetail, isActive, BlogImage, BlogLink, CreatedBy, CreatedDate, UpdateBy, UpdateDate) VALUES ( @Id, @Blogtitle, @Blogdetail, @Isactive, @Blogimage, @Bloglink, @Createdby, @Createddate, @Updateby, @Updatedate )"; DbCommand dbCommand = db.GetSqlStringCommand(sql); db.AddInParameter(dbCommand, "Id", DbType.String, hcBlogEntity.Id); db.AddInParameter(dbCommand, "Blogtitle", DbType.String, hcBlogEntity.Blogtitle); db.AddInParameter(dbCommand, "Blogdetail", DbType.String, hcBlogEntity.Blogdetail); db.AddInParameter(dbCommand, "Isactive", DbType.String, hcBlogEntity.Isactive); db.AddInParameter(dbCommand, "Blogimage", DbType.String, hcBlogEntity.Blogimage); db.AddInParameter(dbCommand, "Bloglink", DbType.String, hcBlogEntity.Bloglink); db.AddInParameter(dbCommand, "Createdby", DbType.String, hcBlogEntity.Createdby); db.AddInParameter(dbCommand, "Createddate", DbType.String, hcBlogEntity.Createddate); db.AddInParameter(dbCommand, "Updateby", DbType.String, hcBlogEntity.Updateby); db.AddInParameter(dbCommand, "Updatedate", DbType.String, hcBlogEntity.Updatedate); db.ExecuteNonQuery(dbCommand, transaction); return(true); }
string getAllBlog() { string BlogData = ""; HcBlogEntity iGet = new HcBlogEntity(); iGet.Isactive = "1"; DataTable dt = (DataTable)ExecuteDB(HCareTaks.AG_GetAllHcBlogRecord, iGet); if (dt.Rows.Count > 0) { foreach (DataRow dpm in dt.Rows) { BlogData += @"<div class='card custome-card' style='background-color: #ffffff' >" + "<a href = '/Home/Packages/" + dpm["ID"] + "' target='_blank'>" + "<img class='card-img-top' src=" + dpm["BlogImage"] + " alt='Packeage iamge'/>" + "<div class='card-body'>" + "<div class='row'>" + "<div class='col-md-8 col-lg-8'>" + "<h4 class='card-title'>" + dpm["BlogTitle"] + "</h4>" + "<p class='card-text text-truncate'>" + dpm["BlogDetail"] + "</p>" + "</div>" + "<div class='col-md-4 col-lg-4'>" + "<a class='btn btn-link' href =" + dpm["BlogLink"] + " target='_blank'> Source </a> " + "</div>" + "</div>" + "</div>" + "</a>" + "</div>"; } } return(BlogData); }