/// <summary> /// 得到一个对象实体 /// </summary> public XCLCMS.Data.Model.Ads GetModel(long AdsID) { XCLCMS.Data.Model.Ads model = new XCLCMS.Data.Model.Ads(); Database db = base.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand("select * from Ads WITH(NOLOCK) where AdsID=@AdsID"); db.AddInParameter(dbCommand, "AdsID", DbType.Int64, AdsID); using (var dr = db.ExecuteReader(dbCommand)) { return(XCLNetTools.DataSource.DataReaderHelper.DataReaderToEntity <XCLCMS.Data.Model.Ads>(dr)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public XCLCMS.Data.Model.Ads GetModel(long AdsID) { XCLCMS.Data.Model.Ads model = new XCLCMS.Data.Model.Ads(); Database db = base.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand("select * from Ads WITH(NOLOCK) where AdsID=@AdsID"); db.AddInParameter(dbCommand, "AdsID", DbType.Int64, AdsID); DataSet ds = db.ExecuteDataSet(dbCommand); var lst = XCLNetTools.Generic.ListHelper.DataTableToList <XCLCMS.Data.Model.Ads>(ds.Tables[0]); return(null != lst && lst.Count > 0 ? lst[0] : null); }
public async Task <APIResponseEntity <bool> > IsExistCode([FromUri] APIRequestEntity <XCLCMS.Data.WebAPIEntity.RequestEntity.Ads.IsExistCodeEntity> request) { return(await Task.Run(() => { #region 初始化 var response = new APIResponseEntity <bool>() { IsSuccess = true, Message = "该唯一标识可以使用!" }; request.Body.Code = (request.Body.Code ?? "").Trim(); XCLCMS.Data.Model.Ads model = null; #endregion 初始化 #region 数据校验 if (string.IsNullOrEmpty(request.Body.Code)) { response.Message = "请指定Code参数!"; response.IsSuccess = false; return response; } #endregion 数据校验 #region 构建response if (request.Body.AdsID > 0) { model = adsBLL.GetModel(request.Body.AdsID); if (null != model && string.Equals(request.Body.Code, model.Code, StringComparison.OrdinalIgnoreCase)) { return response; } } if (adsBLL.IsExistCode(request.Body.Code)) { response.IsSuccess = false; response.Message = "该唯一标识已被占用!"; return response; } return response; #endregion 构建response })); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(XCLCMS.Data.Model.Ads model) { Database db = base.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("sp_Ads_Update"); db.AddInParameter(dbCommand, "AdsID", DbType.Int64, model.AdsID); db.AddInParameter(dbCommand, "Code", DbType.AnsiString, model.Code); db.AddInParameter(dbCommand, "AdsType", DbType.AnsiString, model.AdsType); db.AddInParameter(dbCommand, "Title", DbType.String, model.Title); db.AddInParameter(dbCommand, "Contents", DbType.String, model.Contents); db.AddInParameter(dbCommand, "AdWidth", DbType.Int32, model.AdWidth); db.AddInParameter(dbCommand, "AdHeight", DbType.Int32, model.AdHeight); db.AddInParameter(dbCommand, "URL", DbType.AnsiString, model.URL); db.AddInParameter(dbCommand, "URLOpenType", DbType.AnsiString, model.URLOpenType); db.AddInParameter(dbCommand, "StartTime", DbType.DateTime, model.StartTime); db.AddInParameter(dbCommand, "EndTime", DbType.DateTime, model.EndTime); db.AddInParameter(dbCommand, "NickName", DbType.String, model.NickName); db.AddInParameter(dbCommand, "Email", DbType.AnsiString, model.Email); db.AddInParameter(dbCommand, "QQ", DbType.AnsiString, model.QQ); db.AddInParameter(dbCommand, "Tel", DbType.AnsiString, model.Tel); db.AddInParameter(dbCommand, "OtherContact", DbType.String, model.OtherContact); db.AddInParameter(dbCommand, "Remark", DbType.String, model.Remark); db.AddInParameter(dbCommand, "FK_MerchantID", DbType.Int64, model.FK_MerchantID); db.AddInParameter(dbCommand, "FK_MerchantAppID", DbType.Int64, model.FK_MerchantAppID); db.AddInParameter(dbCommand, "RecordState", DbType.AnsiString, model.RecordState); db.AddInParameter(dbCommand, "CreateTime", DbType.DateTime, model.CreateTime); db.AddInParameter(dbCommand, "CreaterID", DbType.Int64, model.CreaterID); db.AddInParameter(dbCommand, "CreaterName", DbType.String, model.CreaterName); db.AddInParameter(dbCommand, "UpdateTime", DbType.DateTime, model.UpdateTime); db.AddInParameter(dbCommand, "UpdaterID", DbType.Int64, model.UpdaterID); db.AddInParameter(dbCommand, "UpdaterName", DbType.String, model.UpdaterName); db.AddOutParameter(dbCommand, "ResultCode", DbType.Int32, 4); db.AddOutParameter(dbCommand, "ResultMessage", DbType.String, 1000); db.ExecuteNonQuery(dbCommand); var result = XCLCMS.Data.DAL.Common.Common.GetProcedureResult(dbCommand.Parameters); if (result.IsSuccess) { return(true); } else { throw new Exception(result.ResultMessage); } }
public override ActionResult AddSubmit(FormCollection fm) { XCLNetTools.Message.MessageModel msgModel = new XCLNetTools.Message.MessageModel(); var viewModel = this.GetViewModel(fm); var model = new XCLCMS.Data.Model.Ads(); model.AdsID = XCLCMS.Lib.WebAPI.Library.CommonAPI_GenerateID(base.UserToken, new Data.WebAPIEntity.RequestEntity.Common.GenerateIDEntity() { IDType = Data.CommonHelper.EnumType.IDTypeEnum.ADS.ToString() }); model.CreaterID = base.UserID; model.CreaterName = base.CurrentUserModel.UserName; model.CreateTime = DateTime.Now; model.RecordState = viewModel.Ads.RecordState; model.UpdaterID = base.UserID; model.UpdaterName = base.CurrentUserModel.UserName; model.UpdateTime = DateTime.Now; model.FK_MerchantAppID = viewModel.Ads.FK_MerchantAppID; model.FK_MerchantID = viewModel.Ads.FK_MerchantID; model.AdHeight = viewModel.Ads.AdHeight; model.AdsType = viewModel.Ads.AdsType; model.AdWidth = viewModel.Ads.AdWidth; model.Code = viewModel.Ads.Code; model.Contents = viewModel.Ads.Contents; model.Email = viewModel.Ads.Email; model.EndTime = viewModel.Ads.EndTime; model.NickName = viewModel.Ads.NickName; model.OtherContact = viewModel.Ads.OtherContact; model.QQ = viewModel.Ads.QQ; model.Remark = viewModel.Ads.Remark; model.StartTime = viewModel.Ads.StartTime; model.Tel = viewModel.Ads.Tel; model.Title = viewModel.Ads.Title; model.URL = viewModel.Ads.URL; model.URLOpenType = viewModel.Ads.URLOpenType; var request = XCLCMS.Lib.WebAPI.Library.CreateRequest <XCLCMS.Data.Model.Ads>(base.UserToken); request.Body = new Data.Model.Ads(); request.Body = model; var response = XCLCMS.Lib.WebAPI.AdsAPI.Add(request); return(Json(response)); }
public override ActionResult UpdateSubmit(FormCollection fm) { XCLNetTools.Message.MessageModel msgModel = new XCLNetTools.Message.MessageModel(); var viewModel = this.GetViewModel(fm); var model = new XCLCMS.Data.Model.Ads(); model.AdsID = viewModel.Ads.AdsID; model.RecordState = viewModel.Ads.RecordState; model.FK_MerchantAppID = viewModel.Ads.FK_MerchantAppID; model.FK_MerchantID = viewModel.Ads.FK_MerchantID; model.AdHeight = viewModel.Ads.AdHeight; model.AdsType = viewModel.Ads.AdsType; model.AdWidth = viewModel.Ads.AdWidth; model.Code = viewModel.Ads.Code; model.Contents = viewModel.Ads.Contents; model.Email = viewModel.Ads.Email; model.EndTime = viewModel.Ads.EndTime; model.NickName = viewModel.Ads.NickName; model.OtherContact = viewModel.Ads.OtherContact; model.QQ = viewModel.Ads.QQ; model.Remark = viewModel.Ads.Remark; model.StartTime = viewModel.Ads.StartTime; model.Tel = viewModel.Ads.Tel; model.Title = viewModel.Ads.Title; model.URL = viewModel.Ads.URL; model.URLOpenType = viewModel.Ads.URLOpenType; var request = XCLCMS.Lib.WebAPI.Library.CreateRequest <XCLCMS.Data.Model.Ads>(base.UserToken); request.Body = new Data.Model.Ads(); request.Body = model; var response = XCLCMS.Lib.WebAPI.AdsAPI.Update(request); return(Json(response)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(XCLCMS.Data.Model.Ads model) { return(dal.Add(model)); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(XCLCMS.Data.Model.Ads model) { return(dal.Update(model)); }