/// <summary> /// Banner加载数据 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Create(long?id, int identityStatus) { bannerProductModel model = null; ViewBag.ImagePath = ImagePath; if (id.HasValue) { int total = 0; //查询列表 由于是3表连接,关联关键字是商品ID,默认条件是商品语音为中文,如果查不到,请查看bannerProduct,Product_Lang //var result = this._bannerProductService.GetBannerProduct(model); SearchbannerProductModel spmodel = new SearchbannerProductModel(); spmodel.bannerProductId = id.Value; spmodel.IdentityStatus = identityStatus; var result = this._bannerProductService.GetBannerProduct(spmodel, out total).Data as List <bannerProductModel>; //Result result = this._bannerProductService.GetBannerProductById(id.Value); if (result != null && result.Count > 0) { model = result[0]; } } else { model = new bannerProductModel(); model.IdentityStatus = identityStatus;//添加控制位置是否显示出来 } ViewData["BannerPlaceCodeModel1"] = null; if (model.IdentityStatus == 2) { ViewData["BannerPlaceCodeModel1"] = con.GetBannerProducPlaceCodeNameList(ACultureHelper.GetLanguageID, 0, model.IdentityStatus); } //ViewData["IdentityModelBannerCreate"] = con.GetIdentityNameList(new int[] { 1 }); return(PartialView(model)); }
/// <summary> /// 添加banner图片 /// </summary> /// <param name="model">用banner图片模型</param> /// <returns>是否成功</returns> public ResultModel AddBannerProduct(bannerProductModel model) { var result = new ResultModel() { Data = base._database.Db.bannerProduct.Insert(model) }; return(result); }
/// <summary> /// 删除banner图片 /// </summary> /// <param name="model">banner图片模型</param> /// <returns>是否删除成功</returns> public ResultModel DeleteBannerProduct(bannerProductModel model) { var result = new ResultModel() { Data = base._database.Db.bannerProduct.Delete(bannerProductId: model.bannerProductId) }; result.IsValid = result.Data > 0 ? true : false; return(result); }
/// <summary> /// 删除Banner /// </summary> /// <param name="bannerId"></param> /// <returns></returns> public string DeleteBanner(long?bannerId) { bannerProductModel model = new bannerProductModel(); if (bannerId.HasValue) { model.bannerProductId = bannerId.Value; var result = this._bannerProductService.DeleteBannerProduct(model).IsValid; return(result == true ? "Delete success!" : "Delete failed!"); } return("Delete failed!"); }
/// <summary> /// 更新banner图片 /// </summary> /// <param name="model">后banner图片模型</param> /// <returns>是否修改成功</returns> public ResultModel UpdateBannerProduct(bannerProductModel model) { var result = new ResultModel(); if (model.IdentityStatus == 2) { //修改PlaceCode 位置 result.Data = base._database.Db.bannerProduct.UpdateBybannerProductId(bannerProductId: model.bannerProductId, productId: model.productId, PlaceCode: model.PlaceCode, PicAddress: model.PicAddress, UpdateBy: model.UpdateBy, UpdateDT: model.UpdateDT); } else { result.Data = base._database.Db.bannerProduct.UpdateBybannerProductId(bannerProductId: model.bannerProductId, productId: model.productId, PicAddress: model.PicAddress, UpdateBy: model.UpdateBy, UpdateDT: model.UpdateDT); } result.IsValid = result.Data > 0 ? true : false; return(result); }
/// <summary> /// 删除Banner /// </summary> /// <param name="bannerId"></param> /// <returns></returns> public JsonResult DeleteBanner(long?bannerId) { bannerProductModel model = new bannerProductModel(); var resultModel = new ResultModel(); if (bannerId.HasValue) { model.bannerProductId = bannerId.Value; var result = this._bannerProductService.DeleteBannerProduct(model).IsValid; if (result) { resultModel.IsValid = true; resultModel.Messages = new List <string> { "Delete success" }; } else { resultModel.IsValid = false; resultModel.Messages = new List <string> { "Delete failed" }; } var opera = string.Empty; opera = " bannerProductId:" + model.bannerProductId + ",ProductName:" + model.ProductName + ",PicAddress:" + model.PicAddress + ",PlaceCode=" + model.PlaceCode + ",结果:" + resultModel.Messages; LogPackage.InserAC_OperateLog(opera, "APP楼层商品-删除"); return(Json(resultModel, JsonRequestBehavior.AllowGet)); } else { resultModel.IsValid = false; resultModel.Messages = new List <string> { "Parameter ID error" }; } return(Json(resultModel, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 更新banner的Sorts /// </summary> /// <param name="model">需要上下移动的model</param> /// <param name="model">需要上下移动的model对应的上下行model</param> /// <returns>是否修改成功</returns> public ResultModel UpdateSorts(bannerProductModel model, bannerProductModel model1) { var result = new ResultModel(); using (var tx = _database.Db.BeginTransaction()) { try { tx.bannerProduct.UpdateBybannerProductId(bannerProductId: model.bannerProductId, Sorts: model.Sorts, UpdateBy: model.UpdateBy, UpdateDT: model.UpdateDT); tx.bannerProduct.UpdateBybannerProductId(bannerProductId: model1.bannerProductId, Sorts: model1.Sorts, UpdateBy: model1.UpdateBy, UpdateDT: model1.UpdateDT); tx.Commit(); } catch (Exception ex) { tx.Rollback(); result.IsValid = false; result.Messages.Add(ex.Message); } } return(result); }
/// <summary> /// Banner上下移动Sorts(用于列表排序显示) /// </summary> /// <param name="bannerId"></param> /// <param name="sx">1上移动,2下移动</param> /// <returns></returns> public string UpdateSorts(long?bannerId, int sx, long Sorts, int IdentityStatus, int BannerPlaceCode) { bannerProductModel model = new bannerProductModel(); bannerProductModel modelsx = new bannerProductModel(); if (bannerId.HasValue) { //UserInfoModel asuser = UserInfo.GetLoginUserInfo(); //查询 SearchbannerProductModel spmodel = new SearchbannerProductModel(); spmodel.bannerProductId = bannerId.Value; spmodel.IdentityStatus = IdentityStatus; int total = 0; var result1 = this._bannerProductService.GetBannerProduct(spmodel, out total).Data as List <bannerProductModel>; if (result1 != null && result1.Count > 0) { bannerProductModel models = new bannerProductModel(); models = result1[0]; bannerId = models.bannerProductId; BannerPlaceCode = models.PlaceCode; Sorts = models.Sorts; IdentityStatus = models.IdentityStatus; } List <bannerProductModel> ds = null; if (sx == 1) { //获取触发行的上一行数据 var resultlist = this._bannerProductService.GetBannerProduct(Sorts, 1, IdentityStatus, bannerId.Value, 1, BannerPlaceCode); ds = resultlist.Data; if (ds != null && ds.Count > 0) { modelsx = ds[ds.Count - 1]; modelsx.UpdateBy = UserInfo.CurrentUserName; modelsx.UpdateDT = DateTime.Now; var msorts = modelsx.Sorts; modelsx.Sorts = Sorts; //触发行的上一行,把它的排序减一 //this._bannerService.UpdateBanner(smodel); model.Sorts = msorts; //触发行修改的排序 } else { return("This is top line"); } } else { //获取触发行的下一行数据 var resultlist = this._bannerProductService.GetBannerProduct(Sorts, 2, IdentityStatus, bannerId.Value, 1, BannerPlaceCode); ds = resultlist.Data; if (ds != null && ds.Count > 0) { modelsx = ds[0]; modelsx.UpdateBy = UserInfo.CurrentUserName; modelsx.UpdateDT = DateTime.Now; var msorts = modelsx.Sorts; modelsx.Sorts = Sorts; //触发行的下一行,把它排序加一 //this._bannerService.UpdateBanner(smodel1); model.Sorts = msorts; //触发行修改的排序 } else { return("This is last line!"); } } model.bannerProductId = bannerId.Value; model.UpdateBy = UserInfo.CurrentUserName; model.UpdateDT = DateTime.Now; var result = this._bannerProductService.UpdateSorts(model, modelsx).IsValid; return(result == true ? "Move success!" : "Move failed!"); } return("Move failed!"); }
public ActionResult Create(bannerProductModel model) { ViewData["BannerPlaceCodeModel1"] = null; ViewBag.ImagePath = ImagePath; if (model.IdentityStatus == 2) { ViewData["BannerPlaceCodeModel1"] = con.GetBannerProducPlaceCodeNameList(ACultureHelper.GetLanguageID, 0, model.IdentityStatus); } if (ModelState.IsValid) { ResultModel resultModel = new ResultModel(); ProductModel modelp = GetBannerProductByProductId(model.productId); if (modelp == null) { resultModel.Messages = new List <string>() { "Invalid product ID" }; return(Json(resultModel, JsonRequestBehavior.AllowGet)); } if (model.IdentityStatus == 2 && !IsCategoryId(model.productId, model.PlaceCode, model.IdentityStatus)) { ViewBag.messges = "推荐位置(分类)跟商品的分类不相同"; return(PartialView(model)); } if (model.bannerProductId != 0) { model.UpdateBy = UserInfo.CurrentUserName;//asuser.UserName; model.UpdateDT = DateTime.Now; resultModel = this._bannerProductService.UpdateBannerProduct(model); resultModel.Messages = new List <string>() { resultModel.Data > 0 ? "Modify success" : "Modify failed" }; var opera = string.Format("修改首页轮播banner:{0},操作结果:{1}", JsonConverts.ToJson(model), resultModel.Messages); LogPackage.InserAC_OperateLog(opera, "广告管理--首页楼层商品-修改"); } else { model.bannerProductId = MemCacheFactory.GetCurrentMemCache().Increment("commonId"); model.CreateBy = UserInfo.CurrentUserName; model.CreateDT = DateTime.Now; model.UpdateBy = UserInfo.CurrentUserName; model.UpdateDT = DateTime.Now; model.Sorts = MemCacheFactory.GetCurrentMemCache().Increment("commonId"); resultModel.Messages = new List <string>() { this._bannerProductService.AddBannerProduct(model).Data != 0 ? "Add success" : "Add failed" }; var opera = string.Format("添加首页轮播banner:{0},操作结果:{1}", JsonConverts.ToJson(model), resultModel.Messages); LogPackage.InserAC_OperateLog(opera, "广告管理--首页楼层商品-添加"); } return(Json(resultModel, JsonRequestBehavior.AllowGet)); } return(PartialView(model)); }
public void BannerProductService_GetBannerProductById_Test() { bannerProductModel resultModel = this._bannerProductService.GetBannerProductById(973840249).Data; Assert.IsTrue(true); }