Beispiel #1
0
        public async Task <IActionResult> Insert([FromBody] UserSingleDto entity)
        {
            try
            {
                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] UserSingleDto 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}"));
            }
        }