public ActionResult Save(SiteChannelEntity model) { ISiteConfigFacadeService service = ServiceContainer.Instance.Container.Resolve<ISiteConfigFacadeService>(); model.JournalID = CurAuthor.JournalID; ExecResult result = service.SaveSiteChannel(model); return Json(new { result = result.result, msg = result.msg }); }
private SiteChannelEntity GetModel(Int64 ChannelID) { SiteChannelEntity model = null; if (ChannelID > 0) { SiteChannelQuery query = new SiteChannelQuery(); query.JournalID = CurAuthor.JournalID; query.ChannelID = ChannelID; ISiteConfigFacadeService service = ServiceContainer.Instance.Container.Resolve<ISiteConfigFacadeService>(); model = service.GetSiteChannelModel(query); } if (model == null) model = new SiteChannelEntity(); return model; }
public bool AddSiteChannel(SiteChannelEntity siteChannelEntity) { bool flag = false; StringBuilder sqlCommandText = new StringBuilder(); sqlCommandText.Append(" @JournalID"); sqlCommandText.Append(", @PChannelID"); sqlCommandText.Append(", @ContentType"); sqlCommandText.Append(", @IsNav"); sqlCommandText.Append(", @Keywords"); sqlCommandText.Append(", @Description"); sqlCommandText.Append(", @ChannelUrl"); sqlCommandText.Append(", @SortID"); sqlCommandText.Append(", @Status"); DbCommand cmd = db.GetSqlStringCommand(String.Format("INSERT INTO dbo.SiteChannel ({0}) VALUES ({1})",sqlCommandText.ToString().Replace("@", ""),sqlCommandText.ToString())); db.AddInParameter(cmd,"@JournalID",DbType.Int64,siteChannelEntity.JournalID); db.AddInParameter(cmd,"@PChannelID", DbType.Int64, siteChannelEntity.PChannelID); db.AddInParameter(cmd,"@ContentType",DbType.Byte,siteChannelEntity.ContentType); db.AddInParameter(cmd,"@IsNav", DbType.Byte, siteChannelEntity.IsNav); db.AddInParameter(cmd,"@Keywords",DbType.AnsiString,siteChannelEntity.Keywords); db.AddInParameter(cmd,"@Description",DbType.AnsiString,siteChannelEntity.Description); db.AddInParameter(cmd,"@ChannelUrl",DbType.AnsiString,siteChannelEntity.ChannelUrl); db.AddInParameter(cmd,"@SortID",DbType.Int32,siteChannelEntity.SortID); db.AddInParameter(cmd,"@Status",DbType.Byte,siteChannelEntity.Status); try { db.ExecuteNonQuery(cmd); flag = true; } catch(SqlException sqlEx) { throw sqlEx; } return flag; }
public ExecResult Save(SiteChannelEntity model) { ExecResult execResult = new ExecResult(); ISiteChannelService service = ServiceContainer.Instance.Container.Resolve<ISiteChannelService>(); return service.Save(model); }
/// <summary> /// 从存储媒介删除实体数据 /// </summary> /// <param name="siteChannel">SiteChannelEntity实体对象</param> /// <returns>true:删除成功 false:删除失败</returns> public bool DeleteSiteChannel(SiteChannelEntity siteChannel) { return SiteChannelBusProvider.DeleteSiteChannel(siteChannel); }
/// <summary> /// 将实体数据存入存储媒介(持久化一个对象) /// </summary> /// <param name="siteChannel">SiteChannelEntity实体对象</param> /// <returns>true:存储成功 false:存储失败</returns> public bool AddSiteChannel(SiteChannelEntity siteChannel) { return SiteChannelBusProvider.AddSiteChannel(siteChannel); }
/// <summary> /// 更新存储媒介中的实体数据 /// </summary> /// <param name="siteChannel">SiteChannelEntity实体对象</param> /// <returns>true:更新成功 false:更新失败</returns> public bool UpdateSiteChannel(SiteChannelEntity siteChannel) { return SiteChannelBusProvider.UpdateSiteChannel(siteChannel); }
/// <summary> /// 保存栏目 /// </summary> /// <param name="model"></param> /// <returns></returns> public ExecResult Save(SiteChannelEntity model) { ExecResult execResult = new ExecResult(); bool result = false; model.Keywords = model.Keywords.TextFilter(); model.Description = model.Description.TextFilter(); model.ChannelUrl = model.ChannelUrl.TextFilter(); if (model.ChannelID == 0) { result = AddSiteChannel(model); if (result) { execResult.result = EnumJsonResult.success.ToString(); execResult.msg = "新增栏目成功!"; } else { execResult.result = EnumJsonResult.failure.ToString(); execResult.msg = "新增栏目失败!"; } } else { result = UpdateSiteChannel(model); if (result) { execResult.result = EnumJsonResult.success.ToString(); execResult.msg = "修改栏目成功!"; } else { execResult.result = EnumJsonResult.failure.ToString(); execResult.msg = "修改栏目失败!"; } } return execResult; }
public List<SiteChannelEntity> MakeSiteChannelList(IDataReader dr) { List<SiteChannelEntity> list=new List<SiteChannelEntity>(); while(dr.Read()) { SiteChannelEntity siteChannelEntity=new SiteChannelEntity(); siteChannelEntity.ChannelID = (Int64)dr["ChannelID"]; siteChannelEntity.JournalID = (Int64)dr["JournalID"]; siteChannelEntity.PChannelID = (Int64)dr["PChannelID"]; siteChannelEntity.ContentType = (Byte)dr["ContentType"]; siteChannelEntity.IsNav = (Byte)dr["IsNav"]; siteChannelEntity.Keywords = (String)dr["Keywords"]; siteChannelEntity.Description = (String)dr["Description"]; siteChannelEntity.ChannelUrl = (String)dr["ChannelUrl"]; siteChannelEntity.SortID = (Int32)dr["SortID"]; siteChannelEntity.Status = (Byte)dr["Status"]; siteChannelEntity.AddDate = (DateTime)dr["AddDate"]; list.Add(siteChannelEntity); } dr.Close(); return list; }
public bool UpdateSiteChannel(SiteChannelEntity siteChannelEntity) { bool flag = false; StringBuilder whereCommandText = new StringBuilder(); whereCommandText.Append(" ChannelID=@ChannelID"); StringBuilder sqlCommandText = new StringBuilder(); sqlCommandText.Append(" ContentType=@ContentType"); sqlCommandText.Append(", IsNav=@IsNav"); sqlCommandText.Append(", Keywords=@Keywords"); sqlCommandText.Append(", Description=@Description"); sqlCommandText.Append(", ChannelUrl=@ChannelUrl"); sqlCommandText.Append(", SortID=@SortID"); sqlCommandText.Append(", Status=@Status"); DbCommand cmd = db.GetSqlStringCommand(String.Format("UPDATE dbo.SiteChannel SET {0} WHERE {1}",sqlCommandText.ToString(),whereCommandText.ToString())); db.AddInParameter(cmd,"@ChannelID",DbType.Int64,siteChannelEntity.ChannelID); db.AddInParameter(cmd,"@ContentType",DbType.Byte,siteChannelEntity.ContentType); db.AddInParameter(cmd,"@IsNav", DbType.Byte, siteChannelEntity.IsNav); db.AddInParameter(cmd,"@Keywords",DbType.AnsiString,siteChannelEntity.Keywords); db.AddInParameter(cmd,"@Description",DbType.AnsiString,siteChannelEntity.Description); db.AddInParameter(cmd,"@ChannelUrl",DbType.AnsiString,siteChannelEntity.ChannelUrl); db.AddInParameter(cmd,"@SortID",DbType.Int32,siteChannelEntity.SortID); db.AddInParameter(cmd,"@Status",DbType.Byte,siteChannelEntity.Status); try { db.ExecuteNonQuery(cmd); flag = true; } catch(SqlException sqlEx) { throw sqlEx; } return flag; }
public SiteChannelEntity MakeSiteChannel(DataRow dr) { SiteChannelEntity siteChannelEntity=null; if(dr!=null) { siteChannelEntity=new SiteChannelEntity(); siteChannelEntity.ChannelID = (Int64)dr["ChannelID"]; siteChannelEntity.JournalID = (Int64)dr["JournalID"]; siteChannelEntity.PChannelID = (Int64)dr["PChannelID"]; siteChannelEntity.ContentType = (Byte)dr["ContentType"]; siteChannelEntity.IsNav = (Byte)dr["IsNav"]; siteChannelEntity.Keywords = (String)dr["Keywords"]; siteChannelEntity.Description = (String)dr["Description"]; siteChannelEntity.ChannelUrl = (String)dr["ChannelUrl"]; siteChannelEntity.SortID = (Int32)dr["SortID"]; siteChannelEntity.Status = (Byte)dr["Status"]; siteChannelEntity.AddDate = (DateTime)dr["AddDate"]; } return siteChannelEntity; }
public bool DeleteSiteChannel(SiteChannelEntity siteChannelEntity) { bool flag = false; StringBuilder sqlCommandText = new StringBuilder(); sqlCommandText.Append("DELETE FROM dbo.SiteChannel"); sqlCommandText.Append(" WHERE ChannelID=@ChannelID and not exists(select 1 from dbo.SiteChannel b with(nolock) where dbo.SiteChannel.ChannelID=b.PChannelID)"); DbCommand cmd = db.GetSqlStringCommand(sqlCommandText.ToString()); db.AddInParameter(cmd,"@ChannelID",DbType.Int64,siteChannelEntity.ChannelID); try { db.ExecuteNonQuery(cmd); flag = true; } catch(SqlException sqlEx) { throw sqlEx; } return flag; }
/// <summary> /// 从存储媒介删除实体数据 /// </summary> /// <param name="siteChannel">SiteChannelEntity实体对象</param> /// <returns>true:删除成功 false:删除失败</returns> public bool DeleteSiteChannel(SiteChannelEntity siteChannel) { return SiteChannelDataAccess.Instance.DeleteSiteChannel(siteChannel); }
/// <summary> /// 将实体数据存入存储媒介(持久化一个对象) /// </summary> /// <param name="siteChannel">SiteChannelEntity实体对象</param> /// <returns>true:存储成功 false:存储失败</returns> public bool AddSiteChannel(SiteChannelEntity siteChannel) { return SiteChannelDataAccess.Instance.AddSiteChannel(siteChannel); }
/// <summary> /// 保存栏目数据 /// </summary> /// <param name="model"></param> /// <returns></returns> public ExecResult SaveSiteChannel(SiteChannelEntity model) { HttpClientHelper clientHelper = new HttpClientHelper(); ExecResult result = clientHelper.Post<ExecResult, SiteChannelEntity>(GetAPIUrl(APIConstant.SITECHANNEL_SAVE), model); return result; }