Beispiel #1
0
        public JsonResult AddBanner(Banner model)
        {
            if (model == null)
            {
                return(ResponseResult(1, "参数不正确"));
            }
            model = model.DecodeModel() as Banner;
            string errorMsg = bannerApplication.ValidateAndCorrectSubmit(model, imageApplication);

            if (!string.IsNullOrEmpty(errorMsg))
            {
                return(ResponseResult(1, errorMsg));
            }
            model.HTML     = UrlCommon.Decode(model.HTML);
            model.BannerId = SaidCommon.GUID;
            model.Date     = DateTime.Now;
            bannerApplication.Add(model);
            imageApplication.AddReferenceCount(model.ImageId);
            if (bannerApplication.Commit())
            {
                return(ResponseResult(model));
            }
            else
            {
                return(ResponseResult(6, "添加到数据库异常"));
            }
        }