예제 #1
0
        public string RolesTest1()
        {
            try
            {
                RolesEntity rolesEntity = new RolesEntity();
                rolesEntity.ID         = "76d71a4d-daa1-4b9e-885a-be789579a4e5";
                rolesEntity.RolesName  = "李四";
                rolesEntity.CreateDate = DateTime.Now.ToString();
                _rolesRepsonsityService.Update(rolesEntity);
                _rolesRepsonsityService.SaveChange();
            }
            catch (Exception ex)
            {
            }

            return("成功");
        }
예제 #2
0
        public JObject Update([FromBody] RolesEntity _roleEntity)
        {
            DataResult result = new DataResult
            {
                Verifiaction = false
            };

            try
            {
                if (_rolesRepsonsityService.IsExists(x => x.RolesName == _roleEntity.RolesName))
                {
                    result.Message = "因角色名称重复,修改失败!";
                    return(JObject.FromObject(result));
                }

                RolesEntity userEntity = new RolesEntity
                {
                    ID         = _roleEntity.ID,
                    RolesName  = _roleEntity.RolesName,
                    UpdateDate = _roleEntity.UpdateDate.ToString()
                };

                int a = _rolesRepsonsityService.Update(userEntity, new Expression <Func <RolesEntity, object> >[]
                {
                    m => m.RolesName,
                    m => m.UpdateDate,
                    m => m.Remark
                });
                if (a > 0)
                {
                    result.Verifiaction = true;
                    result.Message      = "更新成功";
                }
                else
                {
                    result.Message = "修改失败,可能是数据不存在或已删除!";
                }
            }
            finally
            {
            }
            return(JObject.FromObject(result));
        }