Exemplo n.º 1
0
        public JsonResult Delete(JObject jsonObj)
        {
            //_logger.LogInformation("开始运行");

            AjaxRtnJsonData ajaxRtnJsonData = HandlerHelper.ActionWrap(() =>
            {
                //throw new BusinessException("asdfasdf");

                //参数
                string[] arrayId = HandlerHelper.GetValue(jsonObj, "Id").Split(',');

                IFreeSql fsql = FreeSqlFactory.GetIFreeSql("rlfstock", FreeSql.DataType.Sqlite);

                foreach (string Id in arrayId)
                {
                    StockArt source = fsql.Select <StockArt>().Where(t => t.Id == int.Parse(Id)).ToOne();

                    source.Deleted = 1;

                    fsql.Update <StockArt>().SetSource(source).UpdateColumns(a => a.Deleted).ExecuteAffrows();
                }

                return(null);
            });

            //_logger.LogInformation("结束运行");

            return(new JsonResult(ajaxRtnJsonData));
        }
Exemplo n.º 2
0
        public JsonResult SaveArtContent(JObject jsonObj)
        {
            //_logger.LogInformation("开始运行");

            AjaxRtnJsonData ajaxRtnJsonData = HandlerHelper.ActionWrap(() =>
            {
                //参数
                string Id         = HandlerHelper.GetValue(jsonObj, "Id");
                string ArtContent = HandlerHelper.GetValue(jsonObj, "ArtContent");

                IFreeSql fsql = FreeSqlFactory.GetIFreeSql("rlfstock", FreeSql.DataType.Sqlite);

                StockArt source = fsql.Select <StockArt>().Where(t => t.Id == int.Parse(Id)).ToOne();

                source.ArtContent = ArtContent;

                if (source != null)
                {
                    fsql.Update <StockArt>().SetSource(source).UpdateColumns(a => a.ArtContent).ExecuteAffrows();
                }

                return(null);
            });

            //_logger.LogInformation("结束运行");

            return(new JsonResult(ajaxRtnJsonData));
        }
Exemplo n.º 3
0
        public JsonResult SaveRow(JObject jsonObj)
        {
            //_logger.LogInformation("开始运行");

            AjaxRtnJsonData ajaxRtnJsonData = HandlerHelper.ActionWrap(() =>
            {
                //参数
                string Id = HandlerHelper.GetValue(jsonObj, "Id");

                string ArtTitle = HandlerHelper.GetValue(jsonObj, "ArtTitle");
                string Tag      = HandlerHelper.GetValue(jsonObj, "Tag");

                string UserId = HandlerHelper.GetValue(jsonObj, "UserId");

                //更新/插入
                IFreeSql fsql = FreeSqlFactory.GetIFreeSql("rlfstock", FreeSql.DataType.Sqlite);

                StockArt model = null;

                if (string.IsNullOrEmpty(Id))
                {
                    model = new StockArt();
                }
                else
                {
                    model = fsql.Select <StockArt>().Where(t => t.Id == int.Parse(Id, CultureInfo.CurrentCulture)).ToOne();
                }

                model.ArtTitle = ArtTitle;
                model.Tag      = Tag;

                if (!string.IsNullOrEmpty(Id))
                {
                    fsql.Update <StockArt>().SetSource(model).ExecuteAffrows();
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(UserId))
                    {
                        throw new BusinessException("用户Id为空!");
                    }
                    model.UserId = int.Parse(UserId);
                    fsql.Insert <StockArt>(model).ExecuteAffrows();
                }

                return(null);
            });

            //_logger.LogInformation("结束运行");

            return(new JsonResult(ajaxRtnJsonData));
        }