Пример #1
0
        public async Task <HandleResult> Edit([FromBody] Column model)
        {
            var info = model.Id > 0 ? await _service.GetById(model.Id) : new Column();

            if (info == null)
            {
                return(HandleResult.Error("无效数据"));
            }
            if (model.ParentNum.IsNotEmpty() &&
                string.Equals(info.Num, model.ParentNum, StringComparison.OrdinalIgnoreCase))
            {
                return(HandleResult.Error("无效数据"));
            }

            info.Init();
            ReactForm.SetEditModelValue(info, model, info.Id > 0);

            info.SiteNum = model.SiteNum;
            if (info.ParentNum.IsEmpty())
            {
                info.ParentNum = "";
            }

            var res = info.Id > 0
                ? await _service.Update(info)
                : await _service.Add(info);

            return(res);
        }