Пример #1
0
        public JsonResult UpdateSort(RotationChartViewModel model)
        {
            ResultRetrun rmodel = new ResultRetrun();

            if (string.IsNullOrEmpty(model.SortJson))
            {
                return(Json(rmodel));
            }

            List <RotationSort> rSortList = rotationService.GetRotationSorts();

            if (rSortList.Find(g => g.RotationType == model.RotationType) != null)
            {
                rSortList.Find(g => g.RotationType == model.RotationType).SortList = JsonConvert.DeserializeObject <List <int> >(model.SortJson);
            }
            else
            {
                rSortList.Add(new RotationSort()
                {
                    RotationType = model.RotationType, SortList = JsonConvert.DeserializeObject <List <int> >(model.SortJson)
                });
            }

            rmodel.isSuccess = rotationService.UpdateRotationSort(rSortList);

            return(Json(rmodel));
        }
Пример #2
0
        public JsonResult AddRotation(RotationChartViewModel model)
        {
            ResultRetrun rmodel = new ResultRetrun();

            if (ModelState.IsValid)
            {
                RotationChart downModel = new RotationChart()
                {
                    ImgSrc  = model.HeadImg,
                    Type    = model.RotationType,
                    WebLink = model.WebLink,
                    State   = PublishState.Upper
                };


                List <RotationChart> rlist = rotationService.GetAll(model.RotationType);
                if (rlist != null && model.RotationType == RotationType.Banner && rlist.Count >= 5)
                {
                    rmodel.message = "最多添加Banner轮播不可超过5条";
                    return(Json(rmodel));
                }

                if (rlist != null && model.RotationType == RotationType.Logo && rlist.Count >= 20)
                {
                    rmodel.message = "最多添加Logo轮播不可超过20条";
                    return(Json(rmodel));
                }

                rmodel.isSuccess = rotationService.Add(downModel);
            }

            return(Json(rmodel));
        }
Пример #3
0
        public async Task <IActionResult> GetList(int?wzzid)
        {
            if (wzzid.HasValue)
            {
                var rolist = await _bll.GetAllByWzzId(wzzid.Value);

                return(Json(rolist, new JsonSerializerSettings()
                {
                    ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
                }));
            }
            RotationChartViewModel result = await _bll.GetAll();

            return(Json(result));
        }
Пример #4
0
        public async Task <RotationChartViewModel> GetAll()
        {
            var result  = new RotationChartViewModel();
            var home    = _db.RotationCharts.Where(s => s.WZZModelId == 11);
            var teatype = _db.RotationCharts.Where(s => s.WZZModelId == 13);
            var story   = _db.RotationCharts.Where(s => s.WZZModelId == 14);

            result.HomeRotationChart = await home.ToListAsync();

            result.TeaTypeRotationChart = await teatype.ToListAsync();

            result.StoryRotationChart = await story.ToListAsync();

            return(result);
        }
Пример #5
0
        public JsonResult EditRotation(RotationChartViewModel model)
        {
            ResultRetrun rmodel = new ResultRetrun();

            if (ModelState.IsValid)
            {
                RotationChart data = rotationService.Get(model.Id);
                data.ImgSrc  = model.HeadImg;
                data.Type    = model.RotationType;
                data.WebLink = model.WebLink;

                rmodel.isSuccess = rotationService.Update(data);
            }

            return(Json(rmodel));
        }