Example #1
0
        public IActionResult UpdateLogic(InterfaceAggregation entity)
        {
            SetDataSource();

            if (entity.Id == 0)
            {
                return(View("Update", ResponseModel.Error("修改的id传递错误", entity)));
            }
            if (string.IsNullOrEmpty(entity.Name))
            {
                return(View("Update", ResponseModel.Error("名称不能为空", entity)));
            }
            if (string.IsNullOrEmpty(entity.Code))
            {
                return(View("Update", ResponseModel.Error("编码不能为空", entity)));
            }

            //检查编码或名称重复
            var checkResult = interfaceAggregationService.CheckSameCodeOrName(CurrentMetaObjectId, entity);

            if (!checkResult.IsSuccess)
            {
                return(View("Update", checkResult.ToResponseModel()));
            }

            entity.ModifyBy = CurrentUserId;
            interfaceAggregationService.Update(entity);

            return(RedirectToAction("List"));
        }
Example #2
0
        public IActionResult UpdateLogic(InterfaceAggregation entity)
        {
            ViewData["InterfaceFields"]  = interfaceFieldService.GetEntitiesUnDeletedByMetaObjectId(CurrentMetaObjectId);
            ViewData["SearchConditions"] = searchConditionService.GetEntitiesUnDeletedByMetaObjectId(CurrentMetaObjectId);

            if (entity.Id == 0)
            {
                return(View("Update", ResponseModel.Error("修改的id传递错误", entity)));
            }
            if (string.IsNullOrEmpty(entity.Name))
            {
                return(View("Update", ResponseModel.Error("名称不能为空", entity)));
            }
            if (string.IsNullOrEmpty(entity.Code))
            {
                return(View("Update", ResponseModel.Error("编码不能为空", entity)));
            }

            ////校验code格式
            //if (!entity.Code.IsAlnum(2, 50))
            //{
            //    return View("Add", ResponseModel.Error("编码不合法,2-50位且只能包含字母和数字(字母开头)", entity));
            //}

            //检查编码或名称重复
            var checkResult = interfaceAggregationService.CheckSameCodeOrName(CurrentMetaObjectId, entity);

            if (!checkResult.IsSuccess)
            {
                return(View("Update", checkResult.ToResponseModel()));
            }

            if (entity.InterfaceType == (int)InterfaceType.TriggerScriptDataSource)
            {
                if (string.IsNullOrEmpty(entity.Script))
                {
                    return(View("Add", ResponseModel.Error("触发器脚本不能为空", entity)));
                }
            }
            else
            {
                if (entity.FieldListId == default(int))
                {
                    return(View("Add", ResponseModel.Error("接口字段不能为空", entity)));
                }
                if (entity.SearchConditionId == default(int))
                {
                    return(View("Add", ResponseModel.Error("条件不能为空", entity)));
                }
            }

            interfaceAggregationService.Update(entity);

            return(RedirectToAction("List"));
        }