예제 #1
0
    public async Task <AppSrvResult> UpdateAsync(long id, RoleUpdationDto input)
    {
        var isExists = (await _cacheService.GetAllRolesFromCacheAsync()).Any(x => x.Name == input.Name && x.Id != id);

        if (isExists)
        {
            return(Problem(HttpStatusCode.BadRequest, "该角色名称已经存在"));
        }

        var role = Mapper.Map <SysRole>(input);

        role.Id = id;
        await _roleRepository.UpdateAsync(role, UpdatingProps <SysRole>(x => x.Name, x => x.Tips, x => x.Ordinal));

        return(AppSrvResult());
    }
예제 #2
0
 public async Task <ActionResult> UpdateAsync([FromRoute] long id, [FromBody] RoleUpdationDto input)
 {
     return(Result(await _roleService.UpdateAsync(id, input)));
 }