Beispiel #1
0
        public async Task <ActionResult> AdvertEdit(long adPosId, long id = 0)
        {
            var adPos = await AdPositionRepository.GetByIdAsync(adPosId);

            if (adPos == null)
            {
                var json = new JsonModel {
                    message = string.Format("找不到id为{0}的广告位!", adPosId), statusCode = 300
                };
                return(Json(json, JsonRequestBehavior.AllowGet));
            }
            Advert model;

            if (id > 0)
            {
                model = await AdvertRepository.GetByIdAsync(id);

                if (model == null)
                {
                    var json = new JsonModel {
                        message = string.Format("找不到id为{0}的广告!", id), statusCode = 300
                    };
                    return(Json(json, JsonRequestBehavior.AllowGet));
                }
                model.AdPosName = adPos.Name;
                model.Code      = adPos.Code;
            }
            else
            {
                model = DbFactory.CreateAdvert(adPos.Id, adPos.Code, adPos.Name);
            }
            return(PartialView(model));
        }
Beispiel #2
0
        public async Task <ActionResult> AdvertList(long id, string name, AdvertStatus?status, string orderField, string orderDirection, int pageCurrent = 1, int pageSize = 30)
        {
            var adPos = await AdPositionRepository.GetByIdAsync(id);

            if (adPos == null)
            {
                var json = new JsonModel {
                    message = string.Format("找不到id为{0}的广告位!", id), statusCode = 300
                };
                return(Json(json, JsonRequestBehavior.AllowGet));
            }
            ViewBag.id = id;
            var list = AdvertRepository.GetList(id, name, status, orderField, orderDirection, pageCurrent, pageSize);

            return(PartialView(list));
        }
Beispiel #3
0
        public async Task <ActionResult> Edit(long id = 0)
        {
            AdPosition model;

            if (id > 0)
            {
                model = await AdPositionRepository.GetByIdAsync(id);

                if (model == null)
                {
                    var json = new JsonModel {
                        message = "记录不存在了", statusCode = 300
                    };
                    return(Json(json, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                model = DbFactory.CreateAdPosition();
            }
            return(PartialView(model));
        }
Beispiel #4
0
        public async Task <ActionResult> Edit(AdPosition model)
        {
            ModelState.Remove("ViewName");
            var result = new JsonModel();

            // 数据有误
            if (!ModelState.IsValid)
            {
                result.GetError(ModelState);
                return(Json(result));
            }

            var operationType  = OperationType.Insert;
            var operationTitle = "添加广告位";

            if (model.Id != 0)
            {
                var adPos = await AdPositionRepository.GetByIdAsync(model.Id);

                if (adPos == null)
                {
                    result.message = "记录不存在了";
                    return(Json(result));
                }
                operationType  = OperationType.Update;
                operationTitle = "修改广告位";
            }
            model.ViewName = string.Format("_{0}", model.Code);
            await AdPositionRepository.SaveAsync(model);

            await LogRepository.Insert(TableSource.Users, operationType, operationTitle, model.Id);

            await AttachmentSvc.BoundAttachment(model.Id, model.ImgUrl);

            result.Data    = model;
            result.message = "保存成功!";
            return(Json(result));
        }