Beispiel #1
0
        public async Task <IActionResult> Insert([FromBody] ModuleSingleDto entity)
        {
            try
            {
                var modules = await _service.QueryAsync <ModuleSingleDto>();

                if (modules.Find(it => it.EnCode == entity.EnCode) != null)
                {
                    return(Ok(new { Status = false, Message = "此编码已存在,请重新输入" }));
                }

                int rows = await _service.Insert(entity);//得到影响行数

                if (rows > 0)
                {
                    return(CreateAction());
                }

                return(OKAction(false, "创建失败!原因:影响行数为0"));
            }
            catch (Exception ex)
            {
                return(OKAction(false, $"创建失败!原因:{ex.Message}"));
            }
        }
Beispiel #2
0
        public async Task <IActionResult> Update(string Id, [FromBody] ModuleSingleDto entity)
        {
            try
            {
                entity.Id = Id;
                int rows = await _service.Update(entity);//得到影响行数

                if (rows > 0)
                {
                    return(OKAction(true, "更新成功"));
                }

                return(NotFoundAction(false, "更新失败!原因:影响行数为0"));
            }
            catch (Exception ex)
            {
                return(OKAction(false, $"更新失败!原因:{ex.Message}"));
            }
        }