public IActionResult DeleteRolesByUserid(string rolesid) { try { _logger.Information("Get Roles by user" + rolesid); UserSessionManager usrSession = new UserSessionManager(); var user = User as ClaimsPrincipal; string userId = user.Claims.Where(c => c.Type == "USERID").Select(c => c.Value).SingleOrDefault(); RolesServices rolesServices = new RolesServices { objUser = usrSession.UserLog(userId)._userInfo }; var query = rolesServices.Delete(rolesid); if (query.Result == 1) { var response = new RoleModelOutput { IsSuccess = true, Code = 200, Message = "Success", }; return(Ok(response)); } else { var response = new RoleModelOutput { IsSuccess = false, Code = 422, Message = "error", }; return(Ok(response)); } } catch (Exception ex) { _logger.Error(ex.Message.ToString()); var response = new RoleModelOutput { IsSuccess = false, Code = 422, Message = ex.Message.ToString(), }; return(Ok(response)); } }
public bool DeleteRole(string name) { Role rol = service.GetAllRecords().Where(r => r.Name == name).SingleOrDefault(); try { service.Delete(rol.Id); return(true); } catch (Exception ex) { return(false); throw ex; } }