Exemple #1
0
        /// <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));
        }
Exemple #2
0
        /// <summary>
        /// 列表Banner
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public JsonResult List(SearchbannerProductModel model)
        {
            //SearchAC_OperateLogModel logmodel = new SearchAC_OperateLogModel();
            model.PagedIndex = model.PagedIndex == 0 ? 0 : model.PagedIndex;
            model.PagedSize  = model.PagedSize == 0 ? 10 : model.PagedSize;
            //标识ID 1首页轮播banner,2首页楼层banner,3 分类频道轮播banner,4分类频道楼层banner
            model.IdentityStatus = model.IdentityStatus == null ? 1 : model.IdentityStatus;

            model.LanguageID = ACultureHelper.GetLanguageID;
            int total = 0;
            //查询列表 由于是3表连接,关联关键字是商品ID,默认条件是商品语音为中文,如果查不到,请查看bannerProduct,Product_Lang
            //var result = this._bannerProductService.GetBannerProduct(model);
            var result = this._bannerProductService.GetBannerProduct(model, out total);
            List <bannerProductModel> ds = result.Data;
            var data = new
            {
                rows  = ds,
                total = ds.Count,
            };

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
        /// <summary>
        /// 列表Banner
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public JsonResult List(SearchbannerProductModel model)
        {
            //SearchAC_OperateLogModel logmodel = new SearchAC_OperateLogModel();
            model.PagedIndex = model.PagedIndex == 0 ? 0 : model.PagedIndex;
            model.PagedSize  = model.PagedSize == 0 ? 10 : model.PagedSize;
            //标识ID 1 首页右部的推荐商品,2首页楼层商品,3 APP楼层商品
            model.IdentityStatus = 3;


            int total = 0;
            //查询列表 由于是3表连接,关联关键字是商品ID,默认条件是商品语音为中文,如果查不到,请查看bannerProduct,Product_Lang
            //var result = this._bannerProductService.GetBannerProduct(model);
            var result = this._bannerProductService.GetBannerProduct(model, out total);
            List <bannerProductModel> ds = result.Data;
            var data = new
            {
                rows  = ds,
                total = ds.Count,
            };

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
Exemple #4
0
        /// <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!");
        }
        /// <summary>
        /// 获取banner图片列表
        /// </summary>
        /// <returns>banner图片列表</returns>
        public ResultModel GetBannerProduct(SearchbannerProductModel model)
        {
            var tb = base._database.Db.bannerProduct;

            var where = new SimpleExpression(1, 1, SimpleExpressionType.Equal);
            //商品状态
            where = new SimpleExpression(where, _database.Db.Product.Status == 4, SimpleExpressionType.And);

            if (model.PlaceCode > 0)
            {
                where = new SimpleExpression(where, tb.PlaceCode == model.PlaceCode, SimpleExpressionType.And);//位置(分类)(代表页面里的某个部位)
            }

            if (model.IdentityStatus > 0)
            {
                //标识ID (代表页面)
                where = new SimpleExpression(where, tb.IdentityStatus == model.IdentityStatus, SimpleExpressionType.And);
            }

            var result = new ResultModel();

            dynamic pc;

            var query = _database.Db.bannerProduct
                        .Query()
                        .LeftJoin(_database.Db.Product, out pc)
                        .On(_database.Db.Product.ProductId == _database.Db.bannerProduct.ProductId)
                        .Select(
                tb.productId,
                tb.PicAddress,
                tb.Sorts,
                tb.PlaceCode,
                tb.IdentityStatus,
                tb.CreateBy,
                tb.CreateDT,
                tb.UpdateBy,
                tb.UpdateDT,
                tb.bannerProductId,

                pc.HKPrice,
                pc.CategoryId

                )

                        //.Where(where);
                        //.Where(cl.languageId == null || cl.languageId == model.LanguageID)
                        .Where(where)
                        .OrderBySorts()
                        .ToList <bannerProductModel>()
            ;

            result.Data = query;

            //var result = new ResultModel()
            //{
            //    Data = new SimpleDataPagedList<bannerProductModel>(base._database.Db.bannerProduct.FindAll(where).OrderBySorts(), model.PagedIndex, model.PagedSize)

            //};

            return(result);
        }
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <returns>列表</returns>
        public ResultModel GetBannerProduct(SearchbannerProductModel model, out int total)
        {
            dynamic cl;
            dynamic pc;
            var     tb = base._database.Db.bannerProduct;

            var where = new SimpleExpression(1, 1, SimpleExpressionType.Equal);
            //商品状态
            where = new SimpleExpression(where, _database.Db.Product.Status == 4, SimpleExpressionType.And);
            var result = new ResultModel();

            total = 0;
            if (model.PlaceCode > 0)
            {
                where = new SimpleExpression(where, tb.PlaceCode == model.PlaceCode, SimpleExpressionType.And);//位置(分类)(代表页面里的某个部位)
            }

            if (model.IdentityStatus > 0)
            {
                //标识ID (代表页面)
                where = new SimpleExpression(where, tb.IdentityStatus == model.IdentityStatus, SimpleExpressionType.And);
            }
            if (model.LanguageID > 0)
            {
                //选择语言
                where = new SimpleExpression(where, _database.Db.Product_Lang.languageId == model.LanguageID, SimpleExpressionType.And);
            }
            else
            {
                if (model.IdentityStatus > 1)
                {
                    //1不是楼层
                    where = new SimpleExpression(where, _database.Db.Product_Lang.languageId == 1, SimpleExpressionType.And);
                }
            }
            if (model.productId > 0)
            {
                where = new SimpleExpression(where, _database.Db.Product.productId == model.productId, SimpleExpressionType.And);
            }
            if (model.bannerProductId > 0)
            {
                where = new SimpleExpression(where, tb.bannerProductId == model.bannerProductId, SimpleExpressionType.And);
            }

            var query = _database.Db.bannerProduct
                        //.FindAllBybannerProductId(1215865440)
                        .Query()
                        //.FindAll()
                        .LeftJoin(_database.Db.Product_Lang, out cl)
                        .On(_database.Db.Product_Lang.ProductId == _database.Db.bannerProduct.ProductId)
                        .LeftJoin(_database.Db.Product, out pc)
                        .On(_database.Db.Product.ProductId == _database.Db.bannerProduct.ProductId)
                        .Select(
                tb.productId,
                tb.PicAddress,
                tb.Sorts,
                tb.PlaceCode,
                tb.IdentityStatus,
                tb.CreateBy,
                tb.CreateDT,
                tb.UpdateBy,
                tb.UpdateDT,
                tb.bannerProductId,
                cl.ProductName,
                cl.LanguageID,
                pc.HKPrice,
                pc.CategoryId,
                pc.Status

                )

                        //.Where(where);
                        //.Where(cl.languageId == null || cl.languageId == model.LanguageID)
                        .Where(where)
                        .OrderBySorts()
                        .ToList <bannerProductModel>()
            ;

            //query = query.Skip(model.PagedIndex * model.PagedSize).Take(model.PagedSize).ToList<bannerProductModel>();
            //total = query.Count;


            result.Data = query;
            //result.Data = new SimpleDataPagedList<bannerProductModel>(base._database.Db.bannerProduct.FindAll(where).OrderBySortsDescending(), model.PagedIndex, model.PagedSize);



            return(result);
        }